tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Woodchuck <woodchuc...@yahoo.com>
Subject RE: Tomcat 5.5 classloader log4j vs JCL issue
Date Tue, 06 Sep 2005 18:10:18 GMT
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 log4j.properties 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 log4j.properties file in each web app's
WEB-INF/classes folder.  centralize, as in one log4j.properties 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.


woodchuck


--- Seva Popov <seva_popov@tvworks.com> 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 log4j.properties in ${Tomcat}/common/classes folder.
>  
> Just add into your each web app's WEB-INF/classes folder
> log4j.properties 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 [mailto:mail-lists@revolsys.com] 
> 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.
> http://www.qos.ch/logging/sc.jsp
> 
> 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>com.revolsys.logging.log4j.Log4jServletContextListener</
> 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
> logging.properties 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 
> http://www.yahoo.com/r/hs 
>  
>  
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>  
> 



	
		
______________________________________________________
Click here to donate to the Hurricane Katrina relief effort.
http://store.yahoo.com/redcross-donate3/

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


Mime
View raw message