apache / apache/logging-log4j2

Fix `toString()` method in configuration implementations

Open
#3,599 3 comments 3 reactions 0 assignees View on GitHub
configuration enhancement
Dominant language
Java
Stars
3.6k
Forks
1.7k
Avg merge
1d 20h
Merged PRs (30d)
30

Description

## 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.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the referenced toString() implementation in XmlConfiguration, then compare it with JsonConfiguration and PropertiesConfiguration. Review AbstractConfiguration to determine how the shared implementation should represent the configuration file and its last modification timestamp. Done means the lifecycle log messages consistently contain that information instead of the default object identity.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.