springBoot启动报错log4j冲突的解决方案

网友投稿 761 2022-12-23

springBoot启动报错log4j冲突的解决方案

springBoot启动报错log4j冲突的解决方案

springBoot启动报错log4j冲突

先上一段报错内容

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in [jar:file:/D:/soft/apache-tomcat-8.5.31/webapps/ui/WEB-INF/lib/log4j-slf4j-impl-2.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Found binding in [jar:file:/D:/soft/apache-tomcat-8.5.31/webapps/ui/WEB-INF/lib/logback-classic-1.1.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]

SLF4J: Found binding in [jar:file:/D:/soft/apache-tomcat-8.5.31/webapps/ui/WEB-INF/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]

......

Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback Loggerhttp://Context but Logback is on the classpath. Either remove Logback or the competing implementation (class org.apache.logging.slf4j.Log4jLoggerFactory loaded from file:/D:/soft/apache-tomcat-8.5.31/webapps/ui/WEB-INF/lib/log4j-slf4j-impl-2.7.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.apache.logging.slf4j.Log4jLoggerFactory

springBoot 本地报错,查了一番,是logback搞得鬼,打开pom依赖树,搜索logback,发现在spring-boot-starter-web下有间接依赖上logback-classisc,搜索大神们的解答,就是在有这个依赖的dependency中除去他就行了。

org.springframework.boot

spring-boot-starter-web

ch.qos.logback

logback-classic

SpringBoot启用log4j日志

pom.xml

org.springframework.boot

spring-boot-starter

org.springframework.boot

spring-boot-starter-logging

</exclusion>

org.springframework.boot

spring-boot-starter-log4j

1.2.8.RELEASE

log4j.properties

log4j.rootLogger=debug, ServerDailyRollingFile, stdout

log4j.appender.ServerDailyRollingFile=org.apache.log4j.DailyRollingFileAppender

log4j.appender.ServerDailyRollingFile.DatePattern='.'yyyy-MM-dd

log4j.appender.ServerDailyRollingFile.File=C\://logs/notify-subscription.log

log4j.appender.ServerDailyRollingFile.layout=org.apache.log4j.PatternLayout

log4j.appender.ServerDailyRollingFile.layout.ConversionPattern=%d - %m%n

log4j.appender.ServerDailyRollingFile.Append=true

log4j.appender.stdout=org.apache.log4j.ConsoleAppender

log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} %p [%c] %m%n

log4j.properties放在resources目录下,这个log4j是随便配的。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:车载终端(车载终端可实现的功能不包括什么)
下一篇:中移物联智能车载终端(移动智能车载终端)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~