configuration - Configuring two logback appenders independently -
i might asking trivial, i've tried doesn't seem work. "main" appender, want log "info"s everywhere, except in third-party package (let's call boring
), produces many of them (so @ warnings only). additionally, want log "debug"s in interesting
package. works fine following logback.groovy
:
root(info, ["main"]) logger("interesting", debug, ["main"]) logger("boring", warn, ["main"])
now want configure different appender logging 1 level more like
root(debug, ["detail"]) logger("interesting", trace, ["detail"]) logger("boring", info, ["detail"])
this works, when put both together, doesn't. can imagine caused fact each logger
either on or off given level. i'm aware behavior want, loggers in "boring" package must on info level (because of detail
appender) , messages main
appender filtered, can't see how configure this.
update
i see doing wrong. line
logger("interesting", debug, ["main"])
says nothing "set level debug main appender , package interesting
, below"), 2 independent things instead:
- set level debug package
interesting
, below - add main appender "interesting"
logger
this seems impossible without writing own filter, fortunately pretty easy. ended like
root(debug, ["detail", "main"]) // settings detailed appender logger("interesting", trace) logger("boring", info) appender("main", ...) { ... filter = new myfilter() .deny("boring", info) .accept("interesting", debug) .deny("", debug) }
where deny
, accept
methods adding entries myfilter
. entries evaluated sequentially, i.e.,
- in package
boring
, below, levelinfo
or below gets denied - in package
interesting
, below, leveldebug
or above gets accepted - otherwise, in package, level
debug
or above gets denied
inspired this question.
Comments
Post a Comment