Search code examples
intellij-ideamaven-3java-11

Problem with error SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"


Hello I've got a problem with simple code. I wanted to try to use slf4j with this code

public class App {
public static void main(String[] args) {
    var logger = LoggerFactory.getLogger(App.class);
    logger.info("Hello World!");
}

but I have an error

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.

Can you help me?


Solution

  • Remove <scope>test</scope> from the slf4j-simple dependency and refresh the Maven project in the IDE. With the test scope the dependency will be available only for the code in src/test/java and not available for the main app production code in src/main/java.

    Proof