Monday, May 7, 2007

Configuring a JSF application for logging with log4j

Log4j self initializes itself automatically in Tomcat, by locating a log4j.properties file from the context classpath to configure the log4j system.

I configured logging for a JSF application in which the log4j configuration file initially had the rootLogger set to a logging level of DEBUG. This resulted in a lot of debug statements being generated from the JSF classes. So I changed the root logger's log level to INFO and set the log level of our application classes to DEBUG.

log4j.rootLogger=INFO, A1
log4j.com.logicblox=DEBUG

However, the automatic configuration works only for Tomcat, I believe. I am not sure if it will work in other application servers as well. The log4j system can also be configured by setting the Java system property:

log4j.configuration

No comments: