[logback-user] Different Log Levels For Different Appenders?

Ceki Gulcu listid at qos.ch
Thu Aug 28 09:19:10 CEST 2008


Hello Eric,

I think this is described in chapter 3 of the manual. See "Example 3.9: Logger 
level sample (logback-examples/src/main/java/chapter3/sample4.xml)". The list 
numbering in that chapter only works with Firefox. So on other browsers you 
might see all examples numbered as "3.". See also the next section in the same 
chapter, on "Configuring Appenders", in particular, the cumulative addition of 
appenders. It might be the other "cleaner" way, you are looking for.

HTH,

Eric Faden wrote:
> So suppose I set my root logger to error, but I want to have another 
> logger operate at debug level.  When I do that it makes that loggers 
> level debug for all appenders.  For example take the following
> 
> <configuration>
> 
>   <appender name="*FILE*"
>      ....
>   </appender>
> 
>   <appender name="*STDOUT*"
>      ...
>   </appender>
> 
>   <logger name="mylogger">
>     <level value="debug" />
> **    <appender-ref ref="FILE" />**
>   </logger>
> 
>   <root>
>     <level value="error" />*
>     <appender-ref ref="STDOUT" />*
>   </root>
> </configuration>
> 
> In this example mylogger would output at debug level to BOTH STDOUT
> and FILE.  Is it possible to only get mylogger to output at debug
> level to FILE and error to STDOUT?  I realize that I can add a filter
> to the STDOUT appender to filter anything below ERROR, but I was
> curious if there was another way to do this, possibly cleaner?
> 
> -Eric

-- 
Ceki Gülcü


More information about the Logback-user mailing list