logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ken....@bmwna.com
Subject RE: Problem with logging separation between webapps and container
Date Thu, 06 Nov 2003 16:38:29 GMT
Hi Stephanie -

I don't think we can fully answer your question unless you share with us how
you have implemented the custom repository selector.

In my environment, there is a globally shared security-related jar that is
in the server's classpath (ugh, not my choice) which uses log4j.  We had
used a custom repository selector based on classloaders, and it worked fine
(we have since moved on to a different implementation, though).  The
RepositorySelector is installed by a WebLogic startup class before any
applications are loaded.  Basically everything that is in the server's
classpath has it's own log4j configuration via the default repository, and
each webapp has their own log4j configuration.

Having said all that, I would strongly recommend against putting log4j in
the system classpath, if possible.  Doing so creates a dependency on a
specific version of log4j for all apps deployed on your server, as well as
forcing a particular high-level log4j setup.  For starters, this makes
migration to future versions of log4j difficult, as you will have to
regression test all of your apps.  But if you are already using shared jars,
this may be nothing new for you.

If you are working in an enterprise environment where you have deployed many
different apps developed by many different groups of people, this can lead
to issues with system configuration, maintenance, office politics, and
future new development which would have been easily avoided if you had not
included log4j in the system classpath.  Trust me, I've been there :)

On the other hand, you could hold the pessimistic view that log4j is so
widely used that it's bound to wind up in the server's classpath eventually
anyways.

just my $.02

Ken



> -----Original Message-----
> From: Stephanie.St-Cyr@astrazeneca.com
> [mailto:Stephanie.St-Cyr@astrazeneca.com]
> Sent: Wednesday, November 05, 2003 4:19 PM
> To: log4j-user@jakarta.apache.org
> Subject: Problem with logging separation between webapps and container
> 
> 
> 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


Mime
View raw message