Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making log4j aware of changes in the configuration at runtime

I wonder if there is a non-programatical way of making log4j aware of changes on the configuration at runtime. I know I can use

static {
  PropertyConfigurator.configureAndWatch("log4j.properties", 100);
}

at some useful place to watch a property file for changes, but I would prefer an option within the property file itself, to tell log4j watch for changes. Are there any ?

like image 439
Bastian Spanneberg Avatar asked Nov 06 '22 17:11

Bastian Spanneberg


1 Answers

Log4j has some JMX capabilities which means you can adjust some features dynamically (particularly filtering on level).

Howeever I don't believe you can do much more than that. Appenders have no concept of a lifecycle, which they'd likely need to be able to reliably open/close resources upon reconfiguration.

like image 88
Brian Agnew Avatar answered Nov 15 '22 07:11

Brian Agnew