So, after my long thread to figure out the missing stack traces from a
bad listener configuration, I _thought_ I knew what I needed to
correct.

It seemed that Tomcat was trying to use log4j shipped with my webapp,
before my webapp had configured log4j.
Supplying a log4.properties file in the WEB-INF\classes folder with a
temporary log4j configuration seemed to fix the problem.

Until... I deployed two webapps within tomcat.

The second (and subsequent) webapps _still_ have the problem of trying
to log to a log4j which isn't configured - resulting in all error
messages being lost.

I turned on log4j debugging (-Dlog4j.debug=true) - and here is what I
see as tomcat starts:


INFO: Starting service Catalina
Apr 2, 2009 5:01:22 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/5.5.25
Apr 2, 2009 5:01:22 PM org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
log4j: Trying to find [log4j.xml] using context classloader WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.standardclassloa...@17200b4
.
log4j: Trying to find [log4j.xml] using WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.standardclassloa...@17200b4
 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader
WebappClassLoader
  delegate: false
  repositories:
    /WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.standardclassloa...@17200b4
.
log4j: Using URL
[file:/opt/foo/tomcat/webapps/app1/WEB-INF/classes/log4j.properties]
for automatic log4j configuration.
log4j: Reading configuration from URL
file:/opt/foo/tomcat/webapps/app1/WEB-INF/classes/log4j.properties
log4j: Parsing for [root] with value=[WARN, Console].
<snip>
log4j: Finished configuring.

And then I see output that lets me know that my dynamic configuration
of log4j has occurred.  Everything is good so far.  No warnings have
been shown.
Now, tomcat starts the second webapp - this is all that I see:

log4j:WARN No appenders could be found for logger
(org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.

And then it lets me know that it has finished my dynamic log4j configuration.

So, why didn't log4j try to find the log4j.properties file for the
second webapp?  I'm certainly no guru of how the visibility works
between the webapps and their various classloaders - buy why is log4j
in the second webapp deciding not to configure itself?  And sure
enough, if I break the listener in the web.xml for the second webapp,
the stack trace is lost.

There is definitely a bug here, but I don't know if the bug is in
Tomcat or in Log4j.

Any thoughts?

Thanks,

Dan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to