Skip to content

Fix toString() method in configuration implementations #3599

Open
@ppkarwasz

Description

@ppkarwasz

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:

public String toString() {
return getClass().getSimpleName() + "[location=" + getConfigurationSource() + ", lastModified="
+ Instant.ofEpochMilli(getConfigurationSource().getLastModified()) + "]";
}

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationAffects the configuration system in a general wayenhancementAdditions or updates to features

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions