I\'m getting this error trying to use log4j2 with spring boot.
ERROR StatusLogger Log4j2 could not find a logging implementation.
Please add log4j-core to t
I looked up the source code of LogManager.class and found the reason was there's no LoggerContextFactory found in log4j-provider.properties which should be found in log4j-core.jar/META-INF.
So check your log4j-core.jar/META-INF/log4j-provider.properties file , or you can delete your log4j-core.jar in your local repository.
It looks your dependencies are correct. This is the pom of working spring-boot application with log4j2 as logging framework:
<!-- Spring logging -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
Put your log4j2.xml into resource folder for running from eclipse; if you prefer to use the different directory - resource/conf - provide the path to log4j2 configuration with JVM argument like this:
-Dlog4j.configurationFile=”conf/log4j2.xml”
Do not give up and switch back from logback to log4j2...
That error message is generated by the log4j-api module when it cannot find or load an implementation of its interfaces. Usually this means that the log4j-core module is missing from the classpath, but looking at your dependency graph that doesn't seem to be the case.
There are some transitive dependencies on the log4j-slf4j-impl and log4j-jul modules but I don't think that could cause the error message.
One way to investigate further is to try starting your application again with this system property set: -Dorg.apache.logging.log4j.simplelog.StatusLogger.level=TRACE
. This will print log4j internal debug logging to the console.
(Once your configuration file is loaded the StatusLogger output level can be controlled by setting <Configuration status="trace">
in the beginning of the log4j2.xml configuration file. However, the configuration file is loaded by the log4j-core module, and we're not there yet...)
There might be multiple reasons but common reason is you might have wrong JAR (corrupted). Delete JARs from repository and try to download again. It will solve the problem.
In my case I have deleted org folder from maven repository {home}.m2\repository\org.
I have posted similar question here. Spring boot: ERROR StatusLogger Log4j2 could not find a logging implementation