logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Bischoff <jbisch...@klkurz.com>
Subject Log4j Web-Deployment best practices question
Date Fri, 10 Mar 2006 20:22:37 GMT
I have been using Log4j for the past several months. After reading the 
documentation and the mailing list archives, I am still a bit puzzled 
about the best practices for deploying web-apps that use Log4j.

What I would like to have is a .WAR file for my website that can be 
deployed to either Tomcat or JBoss, without modification. Unfortunately 
it seems that the classloaders of these two servers function a bit 

With Tomcat, I understand that the best practice is to provide your own 
copy of log4j.jar and configuration files inside your WEB-INF folder.

In JBOSS, however, log4j.jar is included by default in the shared /lib/ 
folder. If I so much as put an (identical) copy of log4j.jar in my 
/WEB-INF/lib/ folder, JBOSS throws exceptions while deploying my 
application, and logging fails. (The exception message is at the end of 
this email)

I am currently building my WAR file with no log4j.jar, nor log4j 
configuration files, and deploying successfully to JBoss (modifying the 
default configuration file in JBoss). Unfortunately, now if I want to 
use standalone Tomcat, I have to add things to my WAR file, before I can 
deploy it.

I have considered switching to commons-logging as a wrapper to log4j (a 
trivial conversion). Unfortunately, from what I have read, I will run 
into the same problems with classloading.

14:54:59,312 INFO  [STDOUT] log4j:ERROR A 
"org.jboss.logging.util.OnlyOnceErrorHandler" object is not assignable 
to a "org.apache.log4j.spi.ErrorHandler" variable.
14:54:59,312 INFO  [STDOUT] log4j:ERROR The class 
"org.apache.log4j.spi.ErrorHandler" was loaded by
14:54:59,312 INFO  [STDOUT] log4j:ERROR [WebappClassLoader
   delegate: false
----------> Parent Classloader:
] whereas object of type
14:54:59,312 INFO  [STDOUT] log4j:ERROR 
"org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by 
14:54:59,359 INFO  [STDOUT] log4j:ERROR Could not create an Appender. 
Reported error follows.
14:54:59,359 INFO  [STDOUT] java.lang.ClassCastException: 
...(stack trace follows)

- Jeff Bischoff

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message