logging - Java SLF4J hierachy execution -
there's way execute every log in hierachy particular son?
for example:
-parent -son -son2
- executing son.log("message") execute son log , parent log.
- executing son2.log("message") execute son2, son , parent log.
that's code:
public class helloworld { public static void main(string[] args) { logger parent = loggerfactory.getlogger("parent"); ((ch.qos.logback.classic.logger) parent).setlevel(level.debug); logger son= loggerfactory.getlogger("parent.son"); son.debug("hello"); } }
output:
14:15:25.180 [main] debug logger.son- hello world.
desired output:
14:15:25.180 [main] debug parent.son- hello world. 14:15:25.180 [main] debug parent- hello world.
thanks.
that not how works. slf4j logger hierarchy cannot used (and should not be) in way want.
basically, each logger, if don't define setting, settings copied parent. in hierarchy, logging level set default
parent
, nothing defined parent.son
. logging level parent.son
debug
. logs level higher or equal debug
logged parent.son
. if set log level trace
son, take precedence on parent's debug level.
Comments
Post a Comment