You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Jacob Kjome <ho...@visi.com> on 2003/11/06 06:47:39 UTC

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