相关疑难解决方法(0)

是否需要执行if(log.isDebugEnabled()){...}检查?

有没有必要做一个明确的if(log.isDebugEnabled()){...}检查?

我的意思是我看到一些帖子提到log.debug("something")在进行日志记录之前进行隐式调用以查看是否已启用调试模式日志记录.我错过了什么,或者在使用之前是否有中间步骤?

谢谢!

log.debug("ResultSet rs is retrieved from OracleTypes");
Run Code Online (Sandbox Code Playgroud)

VS

if(log.isDebugEnabled()){
     log.debug("ResultSet rs is retrieved from OracleTypes");
}
Run Code Online (Sandbox Code Playgroud)

编辑:写了这篇文章:http: //java.sg/whether-to-do-a-isdebugenabled-checking-before-printing-out-your-log-statement/

java logging if-statement log4j

42
推荐指数
4
解决办法
3万
查看次数

标签 统计

if-statement ×1

java ×1

log4j ×1

logging ×1