rishi
rishi

Reputation: 1842

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

Upvotes: 1

Views: 1727

Answers (1)

mavarazy
mavarazy

Reputation: 7735

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.

Upvotes: 1

Related Questions