reloading log4j.properties using Log4j Bridge
i have to migrate an existing project from log4j1 to log4j2. The easiest way seems to use the Log4j 1.2 Bridge (https://logging.apache.org/log4j/2.x/log4j-1.2-api/index.html). This works fine, even the existing log4j.properties file can be used. The question that i have is:
Can the log4j.properties file be reloaded periodically at runtime, so that a restart of the application is not neccessary after changing the log4j.properties file?
In log4j1 this could be done using
PropertyConfigurator.configureAndWatch(fileName, 10000);
but it seems this does not work any longer using the bridge.
Solution 1:
You can use the log4j1.monitorInterval
system property:
log4j1.monitorInterval=10
The value is in seconds.
The above mentioned property can be set in any property source, e.g. in log4j2.component.properties
file.