在流中记录日志
2022-09-04 05:28:28
我正在尝试将这段代码转换为Java 8流:
if (list != null && !list.isEmpty()) {
Actor actor = null;
for (Actor actor : list) {
log.info("Actor being read: " actor.getCode());
List<String> areaList = areaDAO.getArea(actor.getCode());
if (!areaList.isEmpty()) {
actor.setArea(areaList.get(0));
log.info("Area{" + areaList.get(0)
+ "} is fetched for actor{" + actor.getCode() + "}.");
}
this.getContext().setReadCount(1);
}
}
但是,在这种情况下,我不确定如何处理日志记录?这是一种好的做法吗?感谢您的帮助。谢谢