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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to