ERROR StatusLogger Reconfiguration failed: No configuration found for '73d16e93' at 'null' in 'null'
Asked Answered
A

5

44

I am using log4j2 the jar files are following: log4j-api-2.14.0.jar log4j-core-2.14.0.jar log4j-slf4j-impl-2.14.0.jar

Executing the following line: LogManager.getLogger("com.foo.Bar1");

using the following VM argument: -Dlog4j.configuration=test1.xml

The config file test1.xml looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
    <Appenders>
        <Console name="Console1" target="SYSTEM_OUT">
            <PatternLayout
                pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
        <File name="MyFile" fileName="test1.txt">
            <PatternLayout>
                <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
            </PatternLayout>
        </File>
    </Appenders>
    <Loggers>
        <Logger name="com.foo.Bar1" level="trace">
            <AppenderRef ref="Console1" />
            <AppenderRef ref="MyFile" />
        </Logger>
    </Loggers>
</Configuration>

the following error occurs when the java file started ERROR StatusLogger Reconfiguration failed: No configuration found for '73d16e93' at 'null' in 'null'

i understand "-Dlog4j.configuration=test1.xml" is wrong. "-Dlog4j.configurationFile=test1.xml" is correct. but i do not understand why the error appears when "-Dlog4j.configuration=test1.xml" is used.

Why the error occurs when -Dlog4j.configuration=test1.xml is used.

Asper answered 9/3, 2021 at 10:56 Comment(0)
H
69

This is because the log4j.configuration expects the file to be in the classpath, while log4j.configurationFile (log4j2.configurationFile for log4j2) expects it as a file path.

If you add -Dlog4j2.debug=true to the VM arguments, you can see which file it is trying to load and will print its path. That way, you will have an indication of why the error is happening.

Hyperdulia answered 17/4, 2021 at 17:50 Comment(1)
Use log4j2.configurationFile instead of log4j.configurationFile.Comparable
I
15

This was exactly the same cryptic error I had, so I updated my VM parameters to

-Dlog4j2.configurationFile=

Instead of

-Dlog4j.configurationFile=

and it solved the issue

notice the 2 in the Dlog4j2

Instal answered 11/7, 2022 at 15:43 Comment(1)
in my case it did not help; my dependencies are like this: ``` <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.20.0</version> </dependency> ```Fulfill
B
5

Log4j 2 has experimental support for Log4j 1.2 configuration files. If you specify -Dlog4j.configuration then Log4j's ConfigurationFactory assumes you want to run in compatibility mode and looks for a configuration file in Log4j 1.x format. If you have provided a file in Log4j2 format obviously that is going to fail, especially if you don't have log4j-1.2-api in your project as that is where the configuration class for Log4j 1.x XML configuration files is.

Barcarole answered 10/3, 2021 at 5:54 Comment(0)
U
1

this problem may occur if you don't have write access to the xml file (a bug from library ? you should only need read access in theory).

dummy workaround : make a copy of this xml file to a location where you have write access and point to it

Unpolitic answered 18/5, 2022 at 11:12 Comment(1)
Thank you so much, adding write permission fixed my issue.Antirachitic
P
1

In my case of getting the same issue it was caused by incorrect log4j file specified

INCORRECT LOGGING_OPTIONS="-Dlog4j.configurationFile=log4j2-sim.xml -Dlog.directory=${STDOUT_DIR}"

CORRECT LOGGING_OPTIONS="-Dlog4j.configurationFile=log4j2.xml -Dlog.directory=${STDOUT_DIR}"

Poison answered 5/9, 2022 at 14:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.