SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.

       Recently, when learning springboot, sometimes it is clear that there is no problem with the project running, but the console will report an error, such as the following problem exception prompt:

        From this, we can see that the main error is the jar package of slf4j, and “failed to load class’ org.slf4j.impl.staticloggerbinder” in the fault code means “failed to load class file org.slf4j.impl.staticloggerbinder”.

The solution published on the official website is:

        This error is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

Translated as follows:

This error was reported when org.slf4j.impl. The staticloggerbinder class cannot be loaded into memory. When this happens, the appropriate slf4j binding classpath cannot be found. The classpath of slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar should solve this problem.

        Therefore, the solution is to load the dependency of one of the above package files (and only one) in the POM file of Maven project. At this time, I load the dependency of “slf4j-nop-1.7.2. Jar” package file, and then the whole project can be compiled without exception.

  1 <dependency>
  2     <groupId>org.slf4j</groupId>
  3     <artifactId>slf4j-nop</artifactId>
  4     <version>1.7.2</version>
  5 </dependency>

Similar Posts: