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

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@qos.ch> To: "logback users list" <logback-user@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 & in an XML file. So '&&' would become '&&'. 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@qos.ch http://qos.ch/mailman/listinfo/logback-user

Robert Elliot wrote:
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.
I can't give you an answer without a more concrete example. How would the config file look like? By the way, don't worry about parsing the config file. Joran, logback's configuration system is extremely flexible, if you can express it in XML, Joran can parse and make sense of it. -- Ceki Gülcü Logback: The reliable, generic, fast and flexible logging framework for Java. http://logback.qos.ch

I can't give you an answer without a more concrete example. How would the config file look like?
Basically, the only change would be an optional level attribute on the appender-ref element; but I'll file a JIRA with full details & some unit tests when I get a bit of time.
By the way, don't worry about parsing the config file. Joran, logback's configuration system is extremely flexible, if you can express it in XML, Joran can parse and make sense of it.
Thanks, I'll definitely use that for prototyping.

I can't give you an answer without a more concrete example. How would the config file look like?
Basically, the only change would be an optional level attribute on the appender-ref element; but I'll file a JIRA with full details & some unit tests when I get a bit of time.
By the way, don't worry about parsing the config file. Joran, logback's configuration system is extremely flexible, if you can express it in XML, Joran can parse and make sense of it.
Thanks, I'll definitely use that in my code.
participants (2)
-
Ceki Gulcu
-
Robert Elliot