Java SLF4J 日志冲突处理

警告信息
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/sunbo/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/sunbo/.m2/repository/org/slf4j/slf4j-log4j12/1.7.26/slf4j-log4j12-1.7.26.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 [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
log4j:WARN No appenders could be found for logger (org.apache.dubbo.common.logger.LoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

SLF4J: Class path contains multiple SLF4J bindings 绑定多个日志处理框架
其实从提示信息里可以看到冲突的依赖SLF4J: Found binding in [jar:file:/Users/sunbo/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]SLF4J: Found binding in [jar:file:/Users/sunbo/.m2/repository/org/slf4j/slf4j-log4j12/1.7.26/slf4j-log4j12-1.7.26.jar!/org/slf4j/impl/StaticLoggerBinder.class]
但是我发现在pom.xml 中并没有这2个依赖,没有办法只能挨个使用

  
                
                    org.slf4j
                    slf4j-log4j12
                
                
                    log4j
                    log4j
                
            

移除依赖最终发现是

  
            org.apache.dubbo
            dubbo-dependencies-zookeeper
            ${dubbo.version}
            pom
            
                
                    org.slf4j
                    slf4j-log4j12
                
                
                    log4j
                    log4j
                
            
        

dubbo里的zookeeper 排除掉就可以了

对于 log4j:WARN No appenders could be found for logger (org.apache.dubbo.common.logger.LoggerFactory). 警告 需要添加如下依赖

 
            org.slf4j
            slf4j-api
            1.7.25
        
        
            org.slf4j
            log4j-over-slf4j
            1.7.25
        
        
            log4j
            log4j
            1.2.17
        

好了 完美运行

你可能感兴趣的:(Java SLF4J 日志冲突处理)