log4j additivity的使用技巧
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, talog4j.logger.com.test = INFO, talog4j.additivity.com.test = false
?
另外一篇参考文章的地址:http://veerasundar.com/blog/2009/08/log4j-tutorial-additivity-what-and-why/