01 解决方案
解决方法如下:
1. 项目的根节点依赖"spring-boot-starter-logging",使每个模块都依赖SpringBoot的日志框架,代码如下:
org.springframework.boot
spring-boot-starter-logging
2.1.17.RELEASE
compile
2. 其它与log有关的模块都exclude排除掉,排除的通用代码如下(这里基本把市面上所有的日志依赖都剔除了):
org.slf4j
slf4j-log4j12
org.slf4j
slf4j-api
org.apache.logging.log4j
log4j-api
org.apache.logging.log4j
log4j-to-slf4j
ch.qos.logback
logback-core
ch.qos.logback
logback-classic
commons-logging
commons-logging
log4j
log4j
org.apache.logging.log4j
log4j-slf4j-impl
org.apache.logging.log4j
log4j-core
02 如何查询哪些依赖引用了log?
直接在项目下的目录,打开命令窗口,输入:
mvn dependency:tree
然后会打印项目中所有的依赖,Ctrl+F
查找“log
”,就可以看到log
依赖到的模块: