logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <Yoav.Shap...@mpi.com>
Subject RE: How Do I Find Out If log4j Has Been Configured?
Date Wed, 28 Apr 2004 20:28:24 GMT

Hi,

>Why can't you simply use a static initializer in your EJB to configure
>Log4J?  I.e:
>
>    static {
>        PropertyConfigurator.configure("myfile.properties");
>    }

I'll answer for the original poster: for several reasons.  What if a 3rd
party library (or another part of the code you simply forgot about) has
already configured log4j?  You'd end up with multiple duplicate
appenders at best, meaning duplicates in the log files.  What if the
application is restarted or classes otherwise reloaded, causing the
static initializer to fire again?  Same story.

Checking if a library has been initialized before initializing it is a
good safe programming practice.  It should be commended and assisted.
Hence the sample code in the log4j wiki and the relevant enhancements in
log4j 1.3.

Yoav Shapira



This e-mail, including any attachments, is a confidential business communication, and may
contain information that is confidential, proprietary and/or privileged.  This e-mail is intended
only for the individual(s) to whom it is addressed, and may not be saved, copied, printed,
disclosed or used by anyone else.  If you are not the(an) intended recipient, please immediately
delete this e-mail from your computer system and notify the sender.  Thank you.


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


Mime
View raw message