Preprocessor logging statements in java

不想你离开。 提交于 2019-12-10 14:02:28

问题


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);
}

回答1:


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




回答2:


Consider using log4j if your example reflects your primary aim.

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



来源:https://stackoverflow.com/questions/3938001/preprocessor-logging-statements-in-java

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!