因框架调整,降级了logback的版本号,由1.3.12降级为1.2.11(因框架限制,只能采用1.2版本),降级后发现debug日志无法打印出来,logback.xml配置文件不生效。后排查发现是与slf4j的版本兼容问题
|---------|--------|--------|
| 依赖包 | 原版本号 | 调整后版本号 |
| logback | 1.2.11 | 未调整 |
| slf4j | 2.0.9 | 1.7.36 |
版本兼容问题发生时,仅显示spring boot版本号,不显示服务启动的端口号,或者提示错误:
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J: Ignoring binding found at [jar:file:/D:/maven/repository/ch/qos/logback/logback-classic/1.2.11/logback-classic-1.2.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.
调整slf4j版本号问题解决。
附logback与slf4j的版本兼容表