log4j配置文件中的additivity属性
它是 子Logger 是否继承 父Logger 的 输出源(appender)的标志位。具体说,默认情况下子Logger会继承父Logger的appender,也就是说子Logger会在父Logger的appender里输出。若是additivity设为false,则子Logger只会在自己的appender里输出,而不会在父Logger的appender里输出。
使用例子:下面是一个log4j的配置文件,父logger是reyo和error,子logger是net
# # Priority = {FATAL|ERROR|WARN|INFO|DEBUG} # # +---------------------------------------------------+ # | root | # +---------------------------------------------------+ # Category - Root # ================ log4j.rootLogger=info,reyo,error log4j.logger.reyo=info,reyo log4j.additivity.reyo=false log4j.logger.net=info,net log4j.additivity.net=false log4j.logger.error=error,error log4j.additivity.error=false # Category - other # ======================================== log4j.logger.org.springframework=ERROR log4j.logger.com.alibaba.druid=ERROR # Appender - stdout # ========================================= log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %l %p: %m%n log4j.appender.stdout.encoding=UTF-8 log4j.appender.reyo=org.apache.log4j.DailyRollingFileAppender log4j.appender.reyo.File=/data/reyo_test/log/reyo.log log4j.appender.reyo.layout=org.apache.log4j.PatternLayout log4j.appender.reyo.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %l %p: %m%n log4j.appender.reyo.encoding=UTF-8 log4j.appender.net=org.apache.log4j.DailyRollingFileAppender log4j.appender.net.File=/data/reyo_test/log/net.log log4j.appender.net.layout=org.apache.log4j.PatternLayout log4j.appender.net.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %l %p: %m%n log4j.appender.net.encoding=UTF-8 log4j.appender.error=org.apache.log4j.DailyRollingFileAppender log4j.appender.error.Threshold=ERROR log4j.appender.error.File=/data/reyo_test/log/error.log log4j.appender.error.layout=org.apache.log4j.PatternLayout log4j.appender.error.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %l %p: %m%n log4j.appender.error.encoding=UTF-8