tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jess Holle <je...@ptc.com>
Subject Re: Web apps vs. Logging vs. Tomcat
Date Thu, 17 Mar 2005 20:48:38 GMT
I had e-mailed this to users mailing list, but I have what I believe is 
a more "dev" follow-on question:

    Is there a good way to get my own start/stop action called at a
    per-VM level?

    This is assuming I end up having to move log4j up into Tomcat's
    classloaders -- at which point I'll want to install my
    LoggerRepository controlling MBeans up at this level as well -- as
    log4j's MBeans have issues and using log4j loggers means you don't
    get the (admittedly sparse) java.util.logging MBean coverage.

--
Jess Holle

Jess Holle wrote:

> 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



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