[logback-user] ContextSelector and getLogger

Ceki Gulcu ceki at qos.ch
Fri Mar 6 10:05:00 CET 2009

Martin Burchard wrote:

 > Using this way, is it possible to have the Logger configuration also
 > on a per Thread basis?

No, SiftingAppender only controls the appenders nested within it. It
does not control the configuration of loggers.

> Reading through Chapter 9: Context Selectors I have seen the
> ContextJNDISelector and now it sounds to me, that ContextSelector isn't such
> a good idea?

Context selection is a possible approach but logback offers other
alternative approaches, e.g. SiftingAppender. Given the unfamiliarity
of your environment, it is not possible to propose the right approach
off the bat.

However, you have correctly identified one problem with context selectors, that 
is static definition of logger variables. This is a known weakness of context 
selectors. However, assuming that you are mostly interested in the logs 
generated by your own code and less about code generated by the libraries you 
use, you could force logger variables to be non-static and just ignore logs 
generated by static logger variables.

Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.

More information about the Logback-user mailing list