I am running an example using log4j 2.0-rc1 and log4j.properties
file, but log4j lib always runs it with the default configuration (log level, appender, etc). I also tried changing the name to log4j2.properties
and nothing happened.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
As of version 2.4, Log4J2 does now, again, support .property files. See here in the documentation for property configuration.
Log4j 2 uses a new configuration file format. You need to use XML (default), JSON (with additional libraries), or even YAML (again, libraries). Check out the documentation.
Log4j 2 doesn't support the Log4j v1 ".properties" format anymore (yet, since v2.4, Log4j supports a Property format, but its syntax is totally different from v1 format). New formats are XML, JSON, and YAML, see the documentation (note: if you used one of these formats in a file called ".properties", it may be confusing).
To specify the location of your configuration file, do you use the system property
log4j.configurationFile
, the Log4j classConfigurationFactory
, or something else? Did you read this manual page? It explains that: Although the Log4j 2 configuration syntax is different than that of Log4j 1.x, most, if not all, of the same functionality is available.So it seems that a legacy Log4j1.x
log4j.properties
file is not supported as is, it must be migrated to v2.x format. The migration seems quite easy though, looking at the example in the link I gave above. Here is an extract:Example of Log4j v1.x config file:
Same config file migrated to Log4j v2: