commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <>
Subject Re: settings log4j settings programmatically
Date Thu, 01 Jan 1970 00:00:00 GMT

---- Dennis Lundberg <> wrote: 
> Jesse Vitrone wrote:
> > Well, I guess the issue is that when we use log4j, we manually configure it, but
when Commons uses log4j, it hasn't been manually configured by us, so I was wondering if there
was a way for Commons Logging to pass our manual configs on to Log4j when Commons initializes
> No, I'm afraid not. Commons logging has its own configuration, but it 
> does not try to pass any configuration on to the underlying logging 
> implementation (log4j in your case).
> > I'm going to look into the wrapper like Jörg suggested.  Any other ideas?
> Jörg's idea is the way to go if you want to make changes in commons 
> logging. But I still think it would be a better solution to make your 
> current configuration reader/handler work seamlessly with log4j. If you 
> can manage that then commons logging will just work.

It's true that commons-logging doesn't initialise the underlying library. That doesn't mean
you can't do it yourself. If your old code used to call an init method from the main() method
in order to initialise log4j then you can still do this; commons-logging just connects to
the log4j system which will already be initialised (I think this is just rephrasing Dennis
was saying above).
However I personally thing Jorg's suggestion is a really good one. Explicitly initialising
your logging from an app's main method will fail if logging is done from static blocks for
example (or from the constructors of objects that are static members of other classes). Writing
your own logger class ensures this can't happen.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message