tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Allistair Crossley" <>
Subject Different behaviour for log4j configuration from common/classes and WEb-INF/classes
Date Wed, 07 Sep 2005 10:07:53 GMT
We've recently noticed that our log4j configuration logs are pretty empty. I decided I must
have changed something that ruptured the configuration, so with a brand new installation of
Tomcat 5.5.11 and a basic log4j config file (shown below) I set about testing what was happening.
Before taking you through the steps, you will see that the log4j file configures appenders
for apache, hibernate and spring. As soon as Tomat initialises the web application I am testing,
both hibernate and spring initialiizations take place.
Test 1
1. Brand new installation of 5.5.11
2. Deploy web application manually 
3. Add to web app's WEB-INF/classes
4. Add log4j1.2.9.jar to web app's WEB-INF/lib
5. Start Tomcat
I move to the Tomcat logs folder (empty) and wait. The stdout_<date>.log is created
(as Tomcat is running as a Windows Service). I see a visible delay of 10 seconds or so with
the file size increasing in this log file (non-log4j) before the log4j configured logs appear.
When Tomcat has fully started up (29s) I note that the log4j logs have no logging, and that
the stdout log has collected all the web app's hibernate and spring logging.
Test 2
0. Clear logs folder
1. Delete from web app's WEB-INF/classes
2. Copy log4j.propeties to catalina.home/common/classes
3. Copy log4j1.2.9.jar to catalina.home/common/lib
4. Copy commons-logging.jar to catalina.home/common/lib
5. Start Tomcat
I move to the Tomcat logs folde (empty) and wait. This time, the log4j configured logs appear
instantly and all at once. A delay takes place until the web app is initialized whereupon
hibernate and spring logging starts getting fed into the appropriate logs as desired.
When the same log4j configuration is used in Tomcat's common/classes (which I presume is first
to be loaded by the class loader) the log configuration is immediately available and the correct
behaviour takes place by the time the web application's classes and libs are loaded.
When the same log4j configuration is used within the web application only, the logs are created
what appears too late and all logging is dumped into the stdout log.
Is this known or understood by anyone?
Thanks, Allistair.
== ==
log4j.rootLogger=DEBUG, RootA
log4j.appender.RootA.layout.ConversionPattern=%d - %5p (%C:%L) - %m%n
# Apache
log4j.appender.ApacheA.layout.ConversionPattern=%d - %5p (%C:%L) - %m%n
log4j.appender.ApacheA.DatePattern=.yyyy-MM-dd, ApacheA
# Hibernate
log4j.appender.HibernateA.layout.ConversionPattern=%d - %5p (%C:%L) - %m%n
log4j.appender.HibernateA.DatePattern=.yyyy-MM-dd, HibernateA
# Spring
log4j.appender.SpringA.layout.ConversionPattern=%d - %5p (%C:%L) - %m%n
log4j.appender.SpringA.DatePattern=.yyyy-MM-dd, SpringA

QAS Ltd.
Registered in England: No 2582055
Registered in Australia: No 082 851 474

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message