springboot log4j2 报错SLF4J: Class path contains multiple SLF4J bindings

写完的springboot后,添加日志配置,习惯用sl4j+log4j配置,网上找了几篇博文参考,配置依赖照写,启动结果报错: Class path contains multiple SLF4J bindings

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/E:/maven_repository_new/org/apache/logging/log4j/log4j-slf4j-impl/2.11.2/log4j-slf4j-impl-2.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/E:/maven_repository_new/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.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.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.StackOverflowError
	at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:108)
	at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:121)
	at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)
	at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
	at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
	at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)

重新又看了这位大神写的博客:原文链接

在pom中加入:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

其他的还确实不管用,加了上面的就OK了,但是大神的分析方法我确实没有在IDEA中看到,不信你看:

在这里插入图片描述

不知道是不是我的idea的版本太低,抽空研究一下,所以后面说的分析也就夭折了,不过分析方法是可以学习一下的,感谢大神的分享[此处有10086朵花花和鼓掌]

发布了81 篇原创文章 · 获赞 10 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/fhf2424045058/article/details/105300198
今日推荐