实例一

切换成SLF4J + Log4J

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-web</artifactId>
  4. <exclusions>
  5. <!--移除SLF4J 和 Logback-->
  6. <exclusion>
  7. <artifactId>logback-classic</artifactId>
  8. <groupId>ch.qos.logback</groupId>
  9. </exclusion>
  10. <exclusion>
  11. <artifactId>log4j-over-slf4j</artifactId>
  12. <groupId>org.slf4j</groupId>
  13. </exclusion>
  14. </exclusions>
  15. </dependency>
  16. <!--引入Log4J,Log4J本身采用SLF4J抽象层,所以会自动引入-->
  17. <dependency>
  18. <groupId>org.slf4j</groupId>
  19. <artifactId>slf4j-log4j12</artifactId>
  20. </dependency>

实例二

切换成SLF4J + Log4J2

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-web</artifactId>
  4. <exclusions>
  5. <!--移除Spring Boot默认的日志场景启动器-->
  6. <exclusion>
  7. <artifactId>spring-boot-starter-logging</artifactId>
  8. <groupId>org.springframework.boot</groupId>
  9. </exclusion>
  10. </exclusions>
  11. </dependency>
  12. <!--直接引入Spring Boot的Log4J2日志场景启动器-->
  13. <dependency>
  14. <groupId>org.springframework.boot</groupId>
  15. <artifactId>spring-boot-starter-log4j2</artifactId>
  16. </dependency>