java中的预处理程序日志记录语句

时间:2010-10-14 22:09:25

标签: java log4j preprocessor

例如我想在编译之前替换:

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

使用:

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

2 个答案:

答案 0 :(得分:5)

别。请使用slf4j,这样可以避免使用{}。

进行检查

答案 1 :(得分:2)

如果您的示例反映了您的主要目标,请考虑使用log4j

Quote needed: Preprocessor usage is bad OO practice也可能会引起人们的兴趣。