Howdy,
A "Configurator" is never configured.  A logging repository is
configured.

One way I've used for testing, although I don't think this is the type
of thing that should be tested at all (keep reading for why), is as
follows:

Logger rootLogger = Logger.getRootLogger();
Enumeration appenders = rootLogger.getAllAppenders();
if((appenders == null) || (appenders instanceof NullEnumeration)) {
 // Log4j hasn't been configured, configure it...
}

I don't think this should be tested because: as a component author, you
state in your installation document/readme/manual that you require
log4j.  You document how log4j can be configured for your use.  This is
a required step for someone using your component.  If they don't do it,
they get the log4j not configured warning that you mention and logging
doesn't work.

If you don't belong in the above bin, you can be in another one: your
documentation will state that the log4j configuration file must reside
in a specific location (e.g. with your component's jar file).  Your
component will then always configure itself from this file.  

I believe either one of the above is better than trying to detect if
you've been configured, and if not using some minimum (in this case
BasicConfigurator) settings.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Jim Mack [mailto:[EMAIL PROTECTED]]
>Sent: Saturday, January 25, 2003 11:39 PM
>To: [EMAIL PROTECTED]
>Subject: How to verify a Configurator is configured
>
>Hello,
>       I am developing some components and I want them to use a
Configurator
>defined outside the component or BasicConfigurator if one is not
defined.
>If
>a Configurator is not defined, several messages are written to standard
out
>i.e. "log4j:WARN Please initialize the log4j system properly." This
message
>seems to suggest that some object knows the system is not correctly
setup,
>but I could not find any methods to get that state. Did I miss
something?
>How can I verify that a Configurator has been configured?
>
>Thanks,
>Jim
>
>
>--
>To unsubscribe, e-mail:   <mailto:log4j-user-
>[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:log4j-user-
>[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to