java中的预处理程序记录语句[英] Preprocessor logging statements in java

本文是小编为大家收集整理的关于java中的预处理程序记录语句的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

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

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

with:

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

推荐答案

不要.代替使用SLF4J,它允许您避免使用{}.

.

其他推荐答案

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

需要报价:所需的报价:preprocorsorser用法不好练习也可能感兴趣.

本文地址:https://www.itbaoku.cn/post/1574997.html

问题描述

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

推荐答案

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

其他推荐答案

Consider using log4j if your example reflects your primary aim.

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