> From: ecmcn [mailto:[email protected]]
> Subject: Verifying initialization
> What are some common techniques for verifying Log4J startup and
> initialization completed successfully?
>
> For a specific example, if DOMConfigurator can't parse my XML config file
> I'll get errors to stdout but nothing that tells my code there was a
> problem. I tried checking for the existence of my Appenders, but it seems
> they're loaded asynchronously. I could loop and wait until they're all
> there, but it seems like I must be missing something obvious.
>
> Any best practices out there?
Hi Eric,
I usually set up my major service containers with: -
static {
// Set a system property to override log4j default initialisation...
System.setProperty("log4j.defaultInitOverride", "true");
}
Then I manually configure with a PropertyConfigurator.configureAndWatch(...) or
DOMConfigurator.configureAndWatch(...).
I usually use custom appenders which I expect to have configured themselves (or
to have failed trying) within a certain amount of time: I log a test message
then wait on a static variable in the Appender class for a short while. Logging
is pretty important for the work I do so it's all about well-tested graceful
failure and fallback.
Regards,
Michael Erskine.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]