12

Does changing Log4j's log.properties require a restart for the changes to take effect?

I'm trying to work out an issue in one of our systems and don't have the ability to restart the server process (OC4J in this case).

Scott Bennett-McLeish
  • 8,908
  • 10
  • 38
  • 45

3 Answers3

14

Yes, since the configuration is loaded upon log4j startup which is loaded upon classloader startup.

cherouvim
  • 30,497
  • 14
  • 99
  • 144
3

PropertyConfigurator.configureAndWatch(java.lang.String configFilename, long delay)

DOMConfigurator.configureAndWatch(java.lang.String configFilename, long delay)

We can use an appropriate delay (in milliseconds) to watch the config file for changes and reload the log4j properties (or xml) without restarting the server.

I am not sure how OC4J behaves, though.

Community
  • 1
  • 1
Vijay Dev
  • 24,306
  • 20
  • 73
  • 96
1

From a different angle, I've recently written a really basic MBean for a different problem and it allows one to change the logger level up and down with a few simple commands.

In my case I'm on Oracle WebLogic using WLST but it's just an MBean, should be accessible from many tools.

Scott Bennett-McLeish
  • 8,908
  • 10
  • 38
  • 45