You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jess Holle <je...@ptc.com> on 2005/03/17 22:11:25 UTC

Web apps vs. Logging vs. Tomcat

I have been trying to get really serious about log4j in web apps.

I note that Tomcat (thanks to commons-logging) uses java.util.logging
*except* for loggers created while my web app's classloader is the
current contextual classloader -- at which point it suddenly uses log4j
(since my web app does) without giving my web app a chance to initialize
it in any way as best I can tell.

My web app has a ServletContextListener which initializes log4j by
setting up its own LoggerRepository, configuration file and watcher
(since log4j's won't shutdown), etc.  Of course, every Tomcat logger
created within my web app up until this point is now using log4j from my
web app (!) and using the basic log4j.properties [if present] from my
web app -- for loggers that apply to all web apps!

How is one supposed to work this?  I am currently using a static
LoggerRepository reference within my web app so that a log4j loaded
higher in the classloader tree won't cause LoggerRepository sharing.  I
was using a JNDI-based LoggerRepositorySelector as per log4j author
recommendations, but this goes a step further than above -- it puts all
the Tomcat loggers that are errantly using my log4j into my
LoggerRepository -- which would be fine if these loggers were not shared
with other web apps.

What's the solution here?  Do I have to put log4j into Tomcat's lib
directories to force it to use its own centralized log4j?  Is that the
best solution?

--
Jess Holle


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