`
lizhou
  • 浏览: 108360 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

log4j additivity的使用技巧

    博客分类:
  • java
 
阅读更多

log4j的additivity属性值默认是设置为true的。可参考其api,地址:http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Category.html#setAdditivityboolean。

 

描述:Additivity is set to true by default, that is children inherit the appenders of their ancestors by default. If this variable is set to false then the appenders found in the ancestors of this category are not used. However, the children of this category will inherit its appenders, unless the children have their additivity flag set to false too. See the user manual for more details.

 

默认为true时,就会产生冗余日志。所以只要设置为false,就可以去除冗余了。

 

log4j.rootLogger = INFO, ta

log4j.logger.com.test = INFO, ta
log4j.additivity.com.test = false

 

另外一篇参考文章的地址:http://veerasundar.com/blog/2009/08/log4j-tutorial-additivity-what-and-why/

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics