spring boot SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"

问题1

1.1 问题描述

spring boot 项目启动时出现日志错误:

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.

1.2 解决方案,增加slf4j实现的相关jar包

例如:
slf4j-simple


    org.slf4j
    slf4j-simple
    1.7.32

slf4j-log4j12


    org.slf4j
    slf4j-log4j12
    1.7.32

或者其他slf4j-nop.jarslf4j-jdk14.jarlogback-classic.jar

注意:只能引入一种依赖,否则易造成jar包冲突。例如: 问题2

问题2

2.1 问题描述

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/work/maven/repository/org/slf4j/slf4j-simple/1.7.32/slf4j-simple-1.7.32.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/work/maven/repository/org/slf4j/slf4j-log4j12/1.7.32/slf4j-log4j12-1.7.32.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]

2.2 解决方案

去除多余的日志依赖就解决了。
由于maven的依赖的传递性,出现这个问题的大多数情况是因为框架依赖jar包中带入了日志依赖,所以解决这个问题的难点在于寻找冲突的日志依赖。

例如:常见依赖spring-boot-starter-web


    org.springframework.boot
    spring-boot-starter-web
    
        
            org.springframework.boot
            spring-boot-starter-logging
        
    

你可能感兴趣的:(spring boot SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder")