0%

spring | 日志框架

spring 不同版本整合的日志框架不一样。

  • spring1,2,3
    • common-logging.jar
  • spring 5.x 默认
    • logback 或者 log4j2

引入

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>2.0.6</version>
<type>pom</type>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

slf4j 引入的原因是让 spring 框架可以支持 log4j

请我喝杯咖啡吧~