[logback-user] Modifying a logging events' level

K.O.Gadellaa at rn.rabobank.nl K.O.Gadellaa at rn.rabobank.nl
Mon Sep 10 08:37:28 CEST 2012

Hi Andrew,

Thanks for the tip.
However, I should have been more clear. I really *do* want to change the logging level.

Deployment&maintenance is done by third party, hence they decide what should be visible at each level (wish that wasn't the case, but...)
Also, it means removing the appender for some cases, e.g.if I want to 'upgrade' an error to WARN & add a specific 'WARN' appender, it works. However, when I only want to see ERROR I also have to remove the appender. Now I know that, but as said, maintenance is not done by me...



Van: logback-user-bounces at qos.ch [mailto:logback-user-bounces at qos.ch] Namens Andrew Bourgeois
Verzonden: vrijdag 7 september 2012 18:47
Aan: logback users list
Onderwerp: Re: [logback-user] Modifying a logging events' level

hello Koos

I don't know how to change the logging level itself, but I assume that what you actually want to do is log these WARN messages with a configuration that has the rootLogger configured at ERROR level.
If that's the case, you can simply declare a separate logger for the packages of that third-party library. In Groovy configuration that gives us:

import ch.qos.logback.classic.encoder.PatternLayoutEncoder
import ch.qos.logback.core.FileAppender
import static ch.qos.logback.classic.Level.*

appender("someAppender", FileAppender) {
  file = "/var/log/test/rootLog.log"
  encoder(PatternLayoutEncoder) {
  pattern = "%date{yyyy-MM-dd HH:mm:ss,SSS} [%thread] %-5level - \\(%logger\\) - %message%n"

root(ERROR, ["someAppender"])

// =======================================================
// This is the logger that will allow WARN messages of your third-party library to log its WARN messages (and above) to the same appender the rootLogger is using.
// "logger(...)" documentation can be found here: http://logback.qos.ch/manual/groovy.html
// =======================================================
logger("com.thirdparty.lib", WARN, ["someAppender"], false)

Best regards
Andrew Bourgeois

From: K.O.Gadellaa at rn.rabobank.nl<mailto:K.O.Gadellaa at rn.rabobank.nl>
Sent: Friday, 07 September, 2012 18:24
To: logback-user at qos.ch<mailto:logback-user at qos.ch>
Subject: [logback-user] Modifying a logging events' level


I'm in the situation where a 3rd party code logs some content at a certain level, but I want that log to be a different (higher) level.
E.g: in my log: WARN : Connection to XYZ failed.
But I want: ERROR: Connection to XYZ failed.

Is there a way to do this with logback?
(couldn't figure it out... maybe with a separate appender?)


Koos Gadellaa

Rabobank disclaimer: http://www.rabobank.nl/disclaimer

Logback-user mailing list
Logback-user at qos.ch
Rabobank disclaimer: http://www.rabobank.nl/disclaimer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120910/87f8aab3/attachment.html>

More information about the Logback-user mailing list