Example
Configuration
Log4j configuration file can be in any of these formats:
- JSON
- YAML
- properties (text file)
- XML
Configuration discovery
- Log4j will inspect the
log4j.configurationFile
system property and, if set, will attempt to load the configuration.
- If no system property is set log4j will look for
log4j2-test.properties
in the classpath.
- If no such file is found the log4j will look for
log4j2-test.yaml
or log4j2-test.yml
in the classpath.
- If no such file is found the log4j will look for
log4j2-test.json
or log4j2-test.jsn
in the classpath.
- If no such file is found the logj4 will look for
log4j2-test.xml
in the classpath.
- If a test file cannot be located the log4j will look for
log4j2.properties
on the classpath.
- If a properties file cannot be located the log4j will look for
log4j2.yaml
or log4j2.yml
on the classpath.
- If a YAML file cannot be located the log4j will look for
log4j2.json
or log4j2.jsn
on the classpath.
- If a JSON file cannot be located the log4j will try to locate
log4j2.xml
on the classpath.
- If no configuration file could be located the DefaultConfiguration will be used. This will cause logging output to go to the console.