[logback-dev] Official "Holler!" concerning my topic on stackoverflow.com

Ceki Gulcu ceki at qos.ch
Mon Jun 8 20:47:48 CEST 2009

Hi Joern,

To set the level of a logger:

   import ch.qos.logback.classic.Logger;

   LoggerContext loggerContext = (LoggerContext) loggerFactory;
   Logger logger = (Logger) loggerContext.getLogger("a.name");
   Level oldLevel = logger.getLevel();
   logger.setLevel(Level.a_level_of_your choice);

To create an appender, there are a bunch of examples under
see for example

Once you create an appender, you can easily associate it with a logger


You can later remove it by invoking

   logger.detachAppender(appender) // detach by appender reference
   logger.detachAppender("appender name"); // detach by name

Let me know if you have further questions. HTH,

Joern Huxhorn wrote:
> Hi Ceki,
> I'm referring to your comment on 
> http://stackoverflow.com/questions/945659/is-there-any-way-to-automatically-execute-junit-testcases-once-with-all-logging-e 
> I've never configured Logback programatically and always assumed that 
> Joran was "the way" to do it. How can this be done?
> I have to admit that I haven't reread the manual concerning this topic, 
> yet,  but thought I'd ask you anyway since it's probably quite easy for 
> you.
> Would you like to integrate the code into a new logback-module (a new 
> module so the compile dependency to JUnit doesn't pollute anything else)?
> After I've enhanced and documented it, obviously...
> I was looking for something like that for more than 4 years so I'm quite 
> happy that I have found such a solution... others would probably 
> benefit, too.
> Regards + thanks,
> Joern.

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

More information about the logback-dev mailing list