Re: [logback-user] logback initialization "à la" Spring

Davide Baroncelli baroncelli at yahoo.com
Fri Sep 28 11:37:15 CEST 2007



Joern Huxhorn wrote:
> 
> Hi Davide.
> 
> It's possible to change the logging configuration at runtime with code 
> like this:
>         ILoggerFactory loggerFactory = LoggerFactory.getILoggerFactory();
> 

Hi, thank you very much for your help: I finally managed to write something
very similar to what's in Spring. You can find it here (
http://www.nabble.com/file/p12937453/logback-web-config.jar here ) in case
someone should be interested. I finally resorted to using 
ContextInitializer.configureByResource( loggerContext, url );
which spares some lines of code.


Joern Huxhorn wrote:
> 
> I've never used  Log4jConfigListener myself so I don't know how it works 
> but doesn't the configuration of the logging environment during normal 
> spring-initializations mean that at least some spring-log-events are 
> swallowed? If this is not the case then everything should be fine.
> 

No, it does not because this is "in Spring" but only from a library
perspective (i.e. you don't need a running application context in order to
use it): it gets configured as a listener or a servlet with init order = 0,
so it is initialized before anything else. The log4jconfiglistener and
servlet in Spring allow configuring also the auto-reload (turn it on-off and
reloading time): since there is no autoreload in logback I stripped this out
of my listener.

-- 
View this message in context: http://www.nabble.com/logback-initialization-%22%C3%A0-la%22-Spring-tf4527977.html#a12937453
Sent from the Logback User mailing list archive at Nabble.com.




More information about the Logback-user mailing list