You could setup Tomcat to have common/lib/log4j.jar and common/classes/log4j.xml. Then the same war should work for both Tomcat and JBoss.
On 3/10/06, Jeff Bischoff <[EMAIL PROTECTED]> wrote: > 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 > differently... > > 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 > repositories: > /WEB-INF/classes/ > ----------> Parent Classloader: > [EMAIL PROTECTED] > ] whereas object of type > 14:54:59,312 INFO [STDOUT] log4j:ERROR > "org.jboss.logging.util.OnlyOnceErrorHandler" was loaded by > [EMAIL PROTECTED] > 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: > org.jboss.logging.appender.DailyRollingFileAppender > ...(stack trace follows) > > - Jeff Bischoff > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- James Stauffer Are you good? Take the test at http://www.livingwaters.com/good/ --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
