简体   繁体   中英

Change logging level dynamically in spring boot app

I have a spring boot app where I provide logging configuration using

-Dlog4j.configuration=file:E:\workspace\log4j.properties

I am using slf4j for logging. Is there any way in which I can just change "log4j.rootLogger" property and log level can be changed dynamically. If not then what should be the best approach to do that in which I can have minimal change in code. Thanks in advance

You can configure monitorInterval in your log4j configuration:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="30">
...
</Configuration>

https://logging.apache.org/log4j/2.x/manual/configuration.html

Log4j will automatically detect changes to the configuration file and reconfigure itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM