Java Programming Tutorials

Java programming tutorials with many code examples!

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

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder” is an error that people face very often. Here we show what is the reason and how to fix it!

Failing Java project

SLF4J-API is only an API


It means that the following JAR contains only interfaces (e.g. Logger) and helper classes, but it is not a logging framework like log4j. It’s just a facade!

Java code that calls SLF4J-API

package com.farenda.loggers;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LoggingWithSlf4j {

    private static final Logger log
            = LoggerFactory.getLogger(LoggingWithSlf4j.class);

    public static void main(String[] args) {"Hello Slf4j!");

The error message when no logging framework present

The above code produces the following output:

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

SLF4J haven’t detected any logging framework so it switched to the only API implementation it has – NOP – that does nothing. :-)

Binding SLF4J to a logging framework

To fix that we need to add a logging framework to our project configuration:


Now, SLF4J will detect at runtime that there is a logging framework on a classpath and will use it for logging. Notice that we’ve declared slf4j-simple in runtime scope, because it is not needed for compilation – our code is using the facade.

Running the same code prints to logs as expected:

[main] INFO com.farenda.loggers.LoggingWithSlf4j - Hello Slf4j!

Logging frameworks bindings

  • slf4j-log4j12: binding for log4j version 1.2
  • slf4j-jdk14: binding for java.util.logging
  • slf4j-nop: binding for NOP (No OPeration)
  • slf4j-simple: binding that prints to System.err
  • slf4j-jcl: binding for Jakarta Commons Logging
  • logback-classic: native implementation.
Share with the World!
  • Roy Eyono

    We need more people like you in the world. You are a genius.