tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Seva Popov" <>
Subject RE: Tomcat 5.5 classloader log4j vs JCL issue
Date Tue, 06 Sep 2005 19:07:52 GMT
Yes it it possible to centralize the logging for the entire container
including all web apps. However, this seems to be a bad practice. The
better approach  is to separate the container internal logging and the
web apps logging. But I guess you know this for yourself.

-----Original Message-----
From: Woodchuck [] 
Sent: Tuesday, September 06, 2005 11:10 AM
To: Tomcat Users List; Seva Popov
Subject: RE: Tomcat 5.5 classloader log4j vs JCL issue

hihi Seva,

yes, your suggestion also works.  i tried it to confirm, and it was my
backup plan to do in case i couldn't figure out how to *not* place
log4j.jar and commons-logging.jar into the ${Tomcat}/common/lib folder.

just fyi, it's also possible to centralize logging for the entire
servlet container by having the file in
${Tomcat}/common/classes (and the log4j.jar in ${Tomcat}/common/lib). 
this way, it is not necessary to put log4j.jar in each web app's
WEB-INF/lib folder, nor the file in each web app's
WEB-INF/classes folder.  centralize, as in one file
and one log4j.jar file.  yet, Tomcat and each web app can still
maintain their own separate log files!  i've tested this and it works
as well.


--- Seva Popov <> wrote:

> Woodchuck,
> I guess, the alternative solution is to have all your web apps use
> log4j
> as well.
> So, you have commons-logging.jar and log4j.jar in the
> ${Tomcat}/common/lib folder
> and in ${Tomcat}/common/classes folder.
> Just add into your each web app's WEB-INF/classes folder
> file and
> into WEB-INF/lib folder log4j.jar.
> This way both Tomcat and your web apps will use separate log4j
> configurations.
> Thanks,
> Seva
> ________________________________
> From: Paul Austin [] 
> Sent: Wednesday, August 31, 2005 1:30 PM
> To: Tomcat Users List
> Subject: Re: Tomcat 5.5 classloader log4j vs JCL issue
> Woodchuck,
> The following web page describes this situation and a solution to the
> problem.
> I have attached the solution that I created this week based on the
> information above. To compile you will need servlet-api.jar and
> log4j.jar to compile.
> Include the jar you create from these files in your web application
> and
> then in your web.xml include the following sections.
> This section can be used if your log4j.xml is not under
> /WEB-INF/log4j.xml
>   <context-param>
>     <param-name>log4jXmlLocation</param-name>
>     <param-value>/WEB-INF/log4j.xml</param-value>
>   </context-param>
> The following calls invokes the listerner when the web app starts up
> to
> create a separate logging context for the web application.
>   <listener>
> listener-class>
>   </listener>
> Also make sure you have a listener that does the following when the
> context is destroyed otherwise you'll get a log of PermGen out of
> memory
> errors after a number of redeploys
>         Introspector.flushCaches();
>         LogFactory.getFactory().release();
> Good luck,
> Paul
> On Wed, 2005-08-31 at 13:03 -0700, Woodchuck wrote: 
> hihi all,
> on my TC 5.5.9 installation i deployed several web applications that
> uses the default JCL logging.  that is, i placed a simple
> file into each web app's WEB-INF/classes folder
> and
> i have per web app logging.  everything works beautifully.
> then i installed a new web app that forced me to place
> commons-logging.jar and log4j.jar into the ${Tomcat}/common/lib
> folder.
>  as a result, all my previous per web app logging no longer works.
> i believe this is because log4j was discovered in the
> ${Tomcat}/common/lib first, and therefore it has superceeded any
> other
> logging system at the (lower) web app level.  this is due to Tomcat's
> classloading process.
> the reason this new web app required commons-logging.jar and
> log4j.jar
> to be placed specifically into the ${Tomcat}/commons/lib folder is
> because it instantiates a log4j logger object in it's start-up
> servlet
> which extends HttpServlet which is found in the servlet-api.jar which
> is also in the ${Tomcat}/commons/lib folder.  this is because
> Tomcat's
> classloading hierarchy dictates that classes in the common/lib cannot
> see web app classes 'downstream'.
> does anyone have any suggestions on how i can have per web app
> logging
> again?  i would like to keep my deployment process as web app
> isolated
> as possible (ie. each web app deployed by WAR, drop it in and that's
> it, no further steps necessary).
> thanks in advance,
> woodchuck
> ____________________________________________________
> Start your day with Yahoo! - make it your home page 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Click here to donate to the Hurricane Katrina relief effort.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message