Tuesday, June 19, 2012

Basic Log4j info

The rootLogger is the one that resides on the top of the logger hierarchy. Here we set its level to DEBUG and added the console appender (CA) to it. The console

appender can have arbitrary name, here its name is CA.

log4j.rootLogger=DEBUG, CA
log4j.appender.CA=org.apache.log4j.ConsoleAppender
log4j.appender.CA.layout=org.apache.log4j.PatternLayout
log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n


Since the rootLogger level is set to DEBUG all the messages are displayed.

The log4j levels follow the following order.


DEBUG
INFO
WARN
ERROR
FATAL

If you set the rootLogger level to WARN then only the WARN, ERROR and FATAL level log messages will be displayed and the rest will be dropped



No comments: