Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change log level of single logger in runtime? [closed]

Tags:

I wanna read spring property and based on this property change log level for some packages (not for root logger). How can I implement it using logback?

like image 930
fedor.belov Avatar asked Aug 07 '13 12:08

fedor.belov


People also ask

Can we change log level at runtime?

In terms of scaling, the challenge is to change log levels in each instance. So to avoid all pitfalls following is needed: Dynamically change the log level at runtime without application restart. Propagation of log level changes across the application instances.

How do you change the logger level?

To change log levels as a root user, perform the following: To enable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=DEBUG) To disable debug logging, run the following command: /subsystem=logging/root-logger=ROOT:change-root-log-level(level=INFO)


1 Answers

See top related question: SLF4J - Logback: How to configure loggers in runtime?

More specific ((ch.qos.logback.classic.Logger)LoggerFactory.getLogger("abc.xyz")) .setLevel(Level.XXX) should do the trick.

I'm not sure what your use case is, but I prefer to use the JMX interface: http://logback.qos.ch/manual/jmxConfig.html.

like image 53
GeertPt Avatar answered Sep 29 '22 13:09

GeertPt