Preprocessor logging statements in java

2019-06-21 16:03发布

for example I want to replace before compilation:

#debug("${enclosing_method} this is debug message for " + userName)

with:

if (log.isDebugEnabled())
{
  log.debug("<real method name> this is debug message for " + userName);
}

2条回答
Juvenile、少年°
2楼-- · 2019-06-21 16:16

Don't. Use slf4j instead which allows you to avoid the check with {}.

查看更多
做个烂人
3楼-- · 2019-06-21 16:20

Consider using log4j if your example reflects your primary aim.

Quote needed: Preprocessor usage is bad OO practice could be of interest as well.

查看更多
登录 后发表回答