Skip to content

Log4j ignores system property configurationFile #2352

@tglaeser

Description

@tglaeser

Description

According to the doumentation, Log4j will inspect the "log4j.configurationFile" system property and, if set, will attempt to load the configuration using the ConfigurationFactory that matches the file extension. In version 2.x this property was named "log4j2.configurationFile". Either way, Log4j seems to ignore this system property. Instead it is sensitive to a system property named "log4j2.*.Configuration.file".

Is this a documentation issue only? How should this be used in version 3.x? Why case sensitive Configuration?

Configuration

Version: 3.0.0-beta2

Operating system: 5.15.133.1-microsoft-standard-WSL2 #1 SMP x86_64 GNU/Linux

JDK: openjdk 17.0.9 2023-10-17

Logs

In addition to above described issue, loading a YAML configuration works with version 3.0.0-beta1 but fails with 3.0.0-beta2:

[Fatal Error] log4j2.yml:1:1: Content is not allowed in prolog.
ERROR StatusLogger Error parsing /config/log4j2.yml
 org.xml.sax.SAXParseException; systemId: file:///config/log4j2.yml; lineNumber: 1; columnNumber: 1; Content is not allowed in prolog.
        at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:262)
        at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:342)
        at org.apache.logging.log4j.core.config.xml.XmlConfiguration.<init>(XmlConfiguration.java:88)

Apparently with the latest version a XmlConfiguration object is created even if the file extension is yml.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    To triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions