springboot中logback和log4j冲突,保留log4j
首先在spring-boot-starter-web中排除spring-boot-starter这个包
然后在spring-boot-starter中排除spring-boot-starter-logging包,此时logback包就被排除了.因为logbak包的上一级parent为spring-boot-starter包
<!--排除spring-boot-starter-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- 去除旧log依赖 -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--引入spring-boot-starter,排除spring-boot-starter-logging-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>