0

I am running a executable jar file, which logs using log4j.xml(version 1.2).

Whenever i change the log level in the xml file, i have to restart the java application for the new log level to reflect.

Can i add some configuration in the log4j.xml so that new log level will be taken into account without application restart?

Thanks, -Venkat

Venkat Teki
  • 2,233
  • 4
  • 21
  • 28

1 Answers1

0

Log4j 1.x has reached end of life on August 5, 2015. So I would like to recommend you to use log4j 2.x which supports this with the monitorInterval configuration.

However according to the log4j 1.x docs here it does support log level changes runtime.

How can I change log behavior at runtime?

Log behavior can be set using configuration files which are parsed at runtime. Using configuration files the programmer can define loggers and set their levels.

The PropertyConfigurator defines a particular format of a configuration file. See also the examples/Sort.java example and associated configuration files.

Configuration files can be specified in XML. See log4j.dtd and org.log4j.xml.DOMConfigurator for more details.

See the various Layout and Appender components for specific configuration options.

In addition to configuration files, the user may disable all messages belonging to a set of levels. See next item.

Rajind Ruparathna
  • 2,215
  • 24
  • 55