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

Reply via email to