执行com.v512.log4j.HelloLog4J时,控制台上的消息是
20120727 15:19:46 INFO com.v512.log4j.HelloLog4J.getMessage(HelloLog4J.java:18) [main] This is a info message.
20120727 15:19:46 WARN com.v512.log4j.HelloLog4J.getMessage(HelloLog4J.java:19) [main] This is a warn message.
20120727 15:19:46 ERROR com.v512.log4j.HelloLog4J.getMessage(HelloLog4J.java:20) [main] This is a error message.
执行com.toogen.log4j.HelloLog4JToogen时
文件Message.log(工程目录下)是
[main] DEBUG com.toogen.log4j.HelloLog4JToogen - This is debug message.
[main] INFO com.toogen.log4j.HelloLog4JToogen - This is a info message.
[main] WARN com.toogen.log4j.HelloLog4JToogen - This is a warn message.
[main] ERROR com.toogen.log4j.HelloLog4JToogen - This is a error message.
总结:加上log4j.additivity.com.toogen.log4j=false后,log4j.rootLogger对com.toogen.log4j的类失效,完全由com.toogen.log4j自己
定义的appender控制,具体说,默认情况下子Logger会继承父Logger的appender。若是additivity设为false,则子Logger只会在自己的appender里输出,而不会在父Logger的appender里输出。