Alex Rivera | Logout

How to dynamically change log level in SLF4j OR Log4J

Asked 2012-11-18T18:06:37.707
31

Recently I encountered a situation where Application Loglevel changes dynamically. Application Admin can set it to INFO/DEBUG/ WARN from front end. Based on the log level choosen be him application logging must be changed.

I am sure loggers support this scenario. How can I achieve this?

Edit
Report

1 Answer

10

Consider Logback http://logback.qos.ch/ - "a successor to the popular log4j project, picking up where log4j leaves off". If instructed to do so, logback-classic will scan for changes in its configuration file and automatically reconfigure itself when the configuration file changes. Besides, you can control Logback's logging levels with JMX.

answered 2012-11-18T18:42:13.277

Your Answer