SpringBoot日志集成引发的LOG4J2的问题
删了写,写了删,不知道要不要写网上的其他解决办法
还是说一下原理(JAR冲突)
百度的话也能搜到一部分解决思路,
不过既然看到我这了估计都没解决,
不过看的话一定要思考
百度搜索的很多都是在web下排除logging
或者是spring-boot-starter排除logging
但未必能解决
说一下我的问题:
1.首先看一下为什么添加log4j2为什么会冲突
你添加的
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
找到spring-boot-starter-web
2.然后ctrl+鼠标进去可以看到这个
3.继续进去(看到了吗?loggion)
4.然后你添加了很多如下;
依旧无效为什么:我们知道了spring-boot-starter下面应该有一个logging
不要想着在spring-boot-starter再添加logging(如果没错应该也会无效)
5.回到最初看一下maven引入的确定只有一个
我试了一下只需要在spring-boot-starter-jdbc下排除即可(附上我的解决代码)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
记得查看maven下的jar(这样对之后的冲突就可以自行查看了),即是自己说的也是对现在的你说的