logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Erskine <michael.ersk...@ketech.com>
Subject RE: Verifying initialization
Date Fri, 11 Sep 2009 10:28:15 GMT
> From: ecmcn [mailto:eric.mcneill@gmail.com]
> 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: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message