[logback-user] Set Level per Logger AND Appender?

Ceki Gulcu listid at qos.ch
Thu Oct 30 14:51:42 CET 2008


I see. You could attach an evaluator fiter which can filter events based on 
criteria that you decide upon. For example,

<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
   <evaluator name="myEval">
     <expression>
       (logger.getName().contains("logger names...") &&  level > INFO)
        ||
        (level > WARN)
      </expression>
   </evaluator>
   <OnMismatch>DENY</OnMismatch>
   <OnMatch>ACCEPT</OnMatch>
</filter>

where "logger names ..." stands for loggers needing special handling.

I am not 100% the above expression is error free but it should at least get my 
point across. In particular, you need to write & as &amp; in an XML file. So 
'&&' would become '&amp;&amp;'.

Does the above help?

Robert Elliot wrote:

 > Because for some loggers I want INFO level statements to be written
 > to application.log (for instance in the case of server startup /
 > shutdown) and for some loggers I don't.  If I set a filter on the
 > appender to only allow WARN or higher to application.log I lose all
 > the INFO statements I wanted- if I set it to allow INFO or higher then
 > if I set a logger to DEBUG then it will start sending INFO messages
 > that I don't want to application.log.

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch


More information about the Logback-user mailing list