[logback-user] Logback configuration

Sebastien Pennec sebastien at qos.ch
Wed Feb 21 16:36:36 CET 2007


Hello Jens,

Logback uses a configuration policy that follows three steps:

1. Check if a logback.xml file is found.
2. If step 1 fails, check if a logback-test-xml file is found
3. If step 2 fails, auto-configure itself with a basic ConsoleAppender.

In step 1, the first logback.xml file that is found is used. If you have multiple 
configuration files available, with the same name, it might cause you some trouble.

To prevent this, you can precise the file you want logback to use by using the 
JoranConfigurator directly.

You can also use the ContextSelector[1] to specify the name of the file you wish to 
load. This way, you'll never have the problem of "first seen, first loaded".

Regards,

Sébastien

[1]http://logback.qos.ch/manual/contextSelector.html


Hausherr, Jens wrote:
> Hi,
>  
> lgoback seems to solve some problems that log4j has, but I did not yet 
> find the answer to my most pressign question: Does logback handle 
> multiple configurations in a controllable manner?
>  
> The crucial problem with log4j was its great propularity not only with 
> application developers but also with library developers that sometimes 
> packed an log4j confguration file into their jars.
>  
> So in almost every project it could happen that one did configure log4j 
> and only get strange or even no output because ther is some other log4j 
> configration overriding the one intended by oneself.
>  
> If logback improves this behavior of log4j I'd be switching immediately 
> with flying colors!
>  
> Regards,
> jens
>  
>  
> 
> 
> This e-mail and any attachment is for authorised use by the intended 
> recipient(s) only. It may contain proprietary material, confidential 
> information and/or be subject to legal privilege. It should not be 
> copied, disclosed to, retained or used by, any other party. If you are 
> not an intended recipient then please promptly delete this e-mail and 
> any attachment and all copies and inform the sender. Thank you.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user

-- 
Sébastien Pennec
sebastien at qos.ch

Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch/



More information about the Logback-user mailing list