logging-log4j2
logging-log4j2 copied to clipboard
Fix `toString()` method in configuration implementations
Description
PR #2941 introduces some basic logging of the most important Configuration lifecycle events at an INFO level. The messages are meant to convey:
- which configuration file is used.
- the last modification timestamp of the file to distinguish between two revisions of the same file.
Unfortunately this information only appears in XmlConfiguration:
https://github.com/apache/logging-log4j2/blob/86781fd8a7d8c07509ba9e430c08333fd82f34bf/log4j-core/src/main/java/org/apache/logging/log4j/core/config/xml/XmlConfiguration.java#L340-L343
JsonConfiguration only prints the name of the configuration file, while PropertiesConfiguration does not have a toString() method at all:
2025-04-04T19:10:16.058147325Z pool-10-thread-1 INFO Stopping configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration@18765d9b...
2025-04-04T19:10:16.058147313Z pool-9-thread-1 INFO Stopping configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration@18f5f66d...
2025-04-04T19:10:16.058631896Z pool-10-thread-1 INFO Configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration@18765d9b stopped.
2025-04-04T19:10:16.058880638Z pool-9-thread-1 INFO Configuration org.apache.logging.log4j.core.config.properties.PropertiesConfiguration@18f5f66d stopped.
We probably should add the toString() method to AbstractConfiguration and remove it from its derived classes.