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

Robert Elliot rob at lidalia.org.uk
Thu Oct 30 14:59:52 CET 2008


It sounds like that would allow the behaviour I would need, thanks very much, I'll use that in future.

I have to confess, however, that it feels rather messy and complicated to maintain.  What do you think of the idea of specifying a level on the combination of logger and appender (effectively the appender-ref)?  With the proviso that you can still specify it on the logger alone as a shorthand for specifying it on all appender-refs?  I'm tempted to protoptype it if you would consider the approach; it would allow a nice clean configuration based on inheritance, and would work with existing logback.xml files as well.

----- Original Message -----
From: "Ceki Gulcu" <listid at qos.ch>
To: "logback users list" <logback-user at qos.ch>
Sent: Thursday, 30 October, 2008 1:51:42 PM GMT +00:00 GMT Britain, Ireland, Portugal
Subject: Re: [logback-user] Set Level per Logger AND Appender?


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
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://qos.ch/mailman/listinfo/logback-user


More information about the Logback-user mailing list