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: Log4j configuration in class libraries
Date Fri, 11 Jul 2003 09:22:10 GMT
Hi Mike,

I'm in almost total agreement with what you've just said.  Logging 
configuration should be set by the application, not its 
libraries.  Libraries shouldn't be adding a log4j.properties or log4j.xml 
file to their classpath, thus triggering automatic log4j 
configuration.  However, the application always has the opportunity to 
explicitly configure things first.  If you do this, automatic configuration 
using the libraries specific configuration file will be avoided, in which 
case you shouldn't have a problem with a library overriding your own 
configuration.  Additionally, you could take advantage of the fact that, 
say, in webapps, resources from WEB-INF/classes are loaded preferentially 
to resources from jars in WEB-INF/lib.  In this case, your own app's 
automatic configuration will run first and, just as in the latter case, 
avoid additonal automatic configuration via another library's configuration 
file.  On the other hand, if a library is explicitly doing configuration in 
some static block or something, that is just totally inappropriate and 
should be very discouraged.

Hope that helps.


At 07:00 PM 7/10/2003 -0700, you wrote:
>Hi there,
>what's the recommended strategy for someone releasing a class
>library which assumes a certain Log4j configuration? I'm assuming
>reading the configuration file should be done only once and in the
>main program, not in a class library.
>Background is that in the Log4perl world, people are sharing modules
>(libraries) on a collaboration network (CPAN), and some of them would
>like to assume that there's a logging behaviour defined for certain
>categories or that certain appenders have been configured.
>Now, that's probably not a good idea, because a library might
>accidentally overwrite something another library has already set -- and
>our recommendation to the module authors has been that only the main
>program should actually do any configuration work. The modules are just
>supposed to give recommendations on what the main program should do.
>How are you guys dealing with this problem? Would be great if you could
>give some insight.
>-- Mike
>Mike Schilli
>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

View raw message