Tuesday, December 14, 2010

Commons Logging - Log4J Configuration

If you use commons-logging in your java application, make sure to have log4j library (jar) and log4j.properties file on the class path. You really don't need much tweaking to get started :)

Simple log4j.properties file:

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

To learn more on jump to log4j manual

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?