log4j2 – Failed to load class “org.slf4j.impl.StaticLoggerBinder”

The Java project is using log4j2, but look like some components are used SLF4J logging and caused the following error message:


SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Solution

To fix it, we need a SLF4J Bridge. Puts log4j-slf4j-impl in the classpath.

pom.xml

	<!-- log4j2 -->
	<dependency>
		<groupId>org.apache.logging.log4j</groupId>
		<artifactId>log4j</artifactId>
		<version>2.11.2</version>
	</dependency>

	<!-- SLF4J Bridge -->
	<dependency>
		<groupId>org.apache.logging.log4j</groupId>
		<artifactId>log4j-slf4j-impl</artifactId>
		<version>2.11.2</version>
	</dependency>

References

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter, or befriend him on Facebook or Google Plus. If you like my tutorials, consider make a donation to these charities.

Comments

avatar