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

发布于 2024-09-27 16:32:35 字数 260 浏览 1 评论 0原文

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

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

为:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

明明#如月 2024-10-04 16:32:35

不。请改用 slf4j,这样您就可以避免使用 {} 进行检查。

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

浅浅淡淡 2024-10-04 16:32:35

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

需要引用:预处理器的使用是不好的面向对象实践 可能是兴趣也是如此。

Consider using log4j if your example reflects your primary aim.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文