问题描述
2011-12-02日去百度面试,有这样一个Log4j代码优化问题大家讨论下怎么解决: Final String name="zhangsan";Final User user=service.getUserByName(name);logger.debug("name:"+name+"user:"+user);大家如何优下面代码?
解决方案
final String name="zhangsan";final User user=service.getUserByName(name);if (logger.isDebugEnabled) { logger.debug("name:" + name + "user:" + user);}
时间: 2024-10-25 00:58:25