Main Tutorials

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 Author

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

Comments

Subscribe
Notify of
7 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Vandana Chaturvedi
4 years ago

It did not resolve my same issue

Vandana Chaturvedi
4 years ago

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.

. ____ _ __ _ _
/\\ / ___’_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | ‘_ | ‘_| | ‘_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
‘ |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.1.9.RELEASE)

Naresh
1 year ago

Thanks. It worked for me.

Oleksandr Sirenko
1 year ago

Thank you!
A little bit higher version helped me

<!-- log4j2 -->
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>2.19.0</version>
    <type>pom</type>
</dependency>

<!-- SLF4J Bridge -->
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>2.19.0</version>
</dependency>
Nick
2 years ago

Hi Mkyong,

I added the Log4j sl4j binding dependency but now i get lot of DEBUG log messages.

Werner Dähn
4 years ago

Saved my day

Rakesh
2 years ago

Worked for me. Thanks dude.