logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject RE: Problem with logging separation between webapps and container
Date Thu, 06 Nov 2003 15:54:30 GMT
At 04:30 PM 11/6/2003 +0100, you wrote:
>That seems a good advice but what can I do in the case of a connection
>pooling shared by each webapp?  Actually, I cannot put these classes in each
>app.
>
>The repository selector in each webapp works fine, but how do I use the
>repository selector for the server logging (like connection pooling)?
>
>many thanks
>
>Steph

You never answered my question about how your repository selector 
distinguishes between logger repositories.  Also, you don't have log4j.jar 
in WEB-INF/lib of any of your webapps, do you?  That would cause Log4j not 
to see the shared classes in the parent classloader.  In your case, I 
recommend removing any log4j.jar files and any jars containing the 
repository selectors from WEB-INF/lib of any and all webapps and putting 
log4j.jar and the jar containing your selectors in CATALINA_HOME/common/lib.

As far as general server logging, you can put a log4j.xml in 
CATALINA_HOME/common/classes and let the server use the default logger 
repository.  Each webapp can use its own config file, but you'll have to 
set the repository selector and configure the repository from your 
webapps.  You can use my log4j servlet context listener to do 
this.  Otherwise, you can set something up in the container to set the 
repository selector before any webapps get deployed.

Try all that and let me know how things work.

Jake


>-----Original Message-----
>From: Jacob Kjome [mailto:hoju@visi.com]
>Sent: November 6, 2003 12:50 AM
>To: Log4J Users List
>Subject: Re: Problem with logging separation between webapps and
>container
>
>
>
>I'd listen to Yoav here and keep your libs with each app.  However, I'm
>wondering why this isn't working for you.  What does your repository
>selector use to distinguish different logger repositories?  Are you sure it
>is actually being used by your webapp?  Note that commons-logging does some
>crazy stuff and could be interfering here.  commons-logging is almost
>reason enough to avoid using Struts, if you ask me (but you didn't, so I
>won't go on).
>
>I've done plenty of testing where log4j.jar is in a global classloader
>which many webapps use and the repository selector stuff works like a charm
>to separate logging without having to put log4j.jar in each
>webapp.  However, I haven't much tested the case where those webapps share
>other libraries in a global classloader, simply because it isn't a very
>controllable environment for a webapp.  Maybe you can keep testing to make
>sure your repository selector is doing what you think it is doing but, in
>the end, I'd still follow Yoav's advice.
>
>Jake
>
>At 10:18 PM 11/5/2003 +0100, you wrote:
> >I'm using Resin Servlet Container.  I have developed librairies(jar files)
> >that are shared by many web applications, I have put my libraries jar in
>the
> >global classpath of the servlet container.  In those librairies, I'm using
> >log4j as logging mechanism with an xml configuration file.  Everything was
> >working fine.
> >
> >The problem I have is when I used log4j with Struts in a webapp.  There is
>a
> >conflict, only the logging from the webapp works.  I understand that this
>is
> >a ClassLoader issue as described in the lo4j documentation.
> >
> >I don't want to configure my libraries logging in each webapp but having
> >this kind of logging configured at the server level.
> >
> >To fix the problem, I tried implementing a custom repository selector
>(taken
> >from the sandbox by Jacob Kjome) in my webapp so that both hierarchies
> >worked at the same time without any conflicts.  Even though it's supposed
>to
> >fix the problem, the webapp logging overwrites the server appenders.  I
>have
> >this warning:
> >
> >log4j:WARN No appenders could be found for logger (DbController.class).
> >log4j:WARN Please initialize the log4j system properly.
> >log4j: Finalizing appender named [CONSOLE].
> >
> >Any ideas on how to make this work?
> >
> >thank in advance,
> >
> >
> >Stephanie St-Cyr
> >Software developer
> >AstraZeneca
> >
> >here is my two xml configuration files:
> >
> >the server one:
> ><?xml version="1.0" encoding="UTF-8"?>
> ><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> >
> ><log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
> >                      debug="true">
> >
> >    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
> >         <layout class="org.apache.log4j.PatternLayout">
> >           <param name="ConversionPattern" value="%t %d{hh:mm:ss} %c %M %p
> >line %L -%m%n"/>
> >         </layout>
> >    </appender>
> >
> >    <root>
> >        <level value="DEBUG"/>
> >        <appender-ref ref="CONSOLE" />
> >    </root>
> >
> >    <!-- database logger -->
> >    <logger name="com.codestudio.util.PoolSkimmerThread"
>additivity="false">
> >      <level value="INFO" />
> >      <appender-ref ref="CONSOLE" />
> >    </logger>
> >    <logger name="com.azrdm.util.DbControler"  additivity="false">
> >      <level value="DEBUG" />
> >      <appender-ref ref="CONSOLE" />
> >    </logger>
> >
> ></log4j:configuration>
> >
> >and the webapp:
> >
> ><?xml version="1.0" encoding="UTF-8"?>
> ><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> >
> ><log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
> >                      debug="true">
> >     <appender name="X" class="org.apache.log4j.ConsoleAppender">
> >         <layout class="org.apache.log4j.PatternLayout">
> >           <param name="ConversionPattern" value="%t %d{hh:mm:ss} %c %M %p
> >line %L -%m%n"/>
> >         </layout>
> >     </appender>
> >     <logger name="org.apache.commons.validator.ValidatorResources"
> >additivity="false">
> >         <level value="WARN"/>
> >         <appender-ref ref="X"/>
> >     </logger>
> >     <logger name="org.apache.struts.validator.ValidatorPlugIn"
> >additivity="false">
> >       <level value="WARN"/>
> >       <appender-ref ref="X"/>
> >     </logger>
> >     <logger name="org.apache.struts.util.PropertyMessageResources"
> >additivity="false">
> >       <level value="WARN"/>
> >       <appender-ref ref="X"/>
> >     </logger>
> >
> ></log4j:configuration>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: log4j-user-help@jakarta.apache.org


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


Mime
View raw message