Allows the configuration of log4j from an external file. See
doConfigure(String, LoggerRepository) for the
expected format.
It is sometimes useful to see how log4j is reading configuration
files. You can enable log4j internal logging by defining the
log4j.debug variable.
As of log4j version 0.8.5, at class initialization time class,
the file
log4j.properties will be searched from the search
path used to load classes. If the file can be found, then it will
be fed to the
PropertyConfigurator.configure(java.net.URL)
method.
The
PropertyConfigurator
does not handle the
advanced configuration features supported by the
org.apache.log4j.xml.DOMConfigurator DOMConfigurator such as
support for org.apache.log4j.spi.Filter Filters, custom
org.apache.log4j.spi.ErrorHandler ErrorHandlers, nested
appenders such as the org.apache.log4j.AsyncAppender
AsyncAppender, etc.
All option
values admit variable substitution. The
syntax of variable substitution is similar to that of Unix
shells. The string between an opening
"${" and
closing
"}" is interpreted as a key. The value of
the substituted variable can be defined as a system property or in
the configuration file itself. The value of the key is first
searched in the system properties, and if not found there, it is
then searched in the configuration file being parsed. The
corresponding value replaces the ${variableName} sequence. For
example, if
java.home
system property is set to
/home/xyz
, then every occurrence of the sequence
${java.home}
will be interpreted as
/home/xyz
.
PropertyConfigurator
does not handle the advanced configuration features supported by the org.apache.log4j.xml.DOMConfigurator DOMConfigurator such as support for org.apache.log4j.spi.Filter Filters, custom org.apache.log4j.spi.ErrorHandler ErrorHandlers, nested appenders such as the org.apache.log4j.AsyncAppender AsyncAppender, etc. All option values admit variable substitution. The syntax of variable substitution is similar to that of Unix shells. The string between an opening "${" and closing "}" is interpreted as a key. The value of the substituted variable can be defined as a system property or in the configuration file itself. The value of the key is first searched in the system properties, and if not found there, it is then searched in the configuration file being parsed. The corresponding value replaces the ${variableName} sequence. For example, ifjava.home
system property is set to/home/xyz
, then every occurrence of the sequence${java.home}
will be interpreted as/home/xyz
.