Log4j2 could not find a logging implementation with Spring Boot
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...)