Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.14.1
-
None
Description
I am setting `LOG4J_CONFIGURATION_FILE` as an environment variable, and also have a `log4j2.component.properties` file that specifies a different value for `log4j2.configurationFile`.
When `PropertyUtils$Environment.reload` handles each key value pair and normalizes the key, `EnvironmentPropertySource.getNormalForm` normalizes the environment variable to `LOG4J_CONFIGURATION_FILE` but `PropertiesPropertySource.getNormalForm` normalizes the property from the file as `log4j2.configurationFile`. So both values end up in the `normalized` Map.
Then when `ConfigurationFactory` gets the configuration file property it only looks for `log4j.configurationFile` and ignores the LOG4J_CONFIGURATION_FILE environment variable.
This seems to contradict the documentation which says that environment variables should take precedence over properties files.
If I'm not mistaken and this is truly a bug, then I'd be happy to work on a PR if it would get it resolved more quickly. I would just need some guidance about the proper solution. Should `EnvironmentPropertySource.getNormalForm` be updated to produce the same style output as `PropertyPropertySource.getNormalForm`? The tests indicate that the current behavior is not an accident, so I'm unsure what ought to be done.
Attachments
Issue Links
- Is contained by
-
LOG4J2-3366 Fix order of property sources
- Resolved
- relates to
-
LOG4J2-3621 Log4J 2.19 breaks contract of order of loading of System Properties
- Resolved
- links to