[logback-user] Modifying a logging events' level

Andrew Bourgeois andrew.bourgeois at demmel.be
Fri Sep 7 18:46:48 CEST 2012


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 
Sent: Friday, 07 September, 2012 18:24
To: logback-user at qos.ch 
Subject: [logback-user] Modifying a logging events' level

Hi,

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?)

Regards,

Koos Gadellaa




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



--------------------------------------------------------------------------------
_______________________________________________
Logback-user mailing list
Logback-user at qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/logback-user/attachments/20120907/7dfeb6cf/attachment.html>


More information about the Logback-user mailing list