springboot项目日志不打印
错误信息如下:
SLF4J(W): No SLF4J providers were found.
SLF4J(W): Defaulting to no-operation (NOP) logger implementation
SLF4J(W): See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J(W): Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J(W): Ignoring binding found at [jar:file:/D:/m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J(W): See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.
原因分析:
目前项目使用的版本是springboot-2.3.12.RELEASE,此报错提示的是SLF4J的版本太高,可能依赖中有引入高版本的SLF4J,在项目启动类所在的pom文件的开头指定SLF4J的版本即可。
<dependencies> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>1.7.30</version> </dependency> ......
参考链接:
Java日志通关(二)- Slf4j+Logback 整合及排包
JAVA日志依赖冲突解决总结_java 使用logback 日志记录,排除log4j的依赖包-CSDN博客
Slf4j 包老冲突, 到底怎么解决?-CSDN博客
slf4j-api下的log4j与logback包冲突 - 简书