Skip to content

Commit cd110e4

Browse files
authored
Update 73.2 Configure Log4j for logging.md
1 parent 89112d6 commit cd110e4

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

IX. ‘How-to’ guides/73.2 Configure Log4j for logging.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
### 73.2 配置Log4j
22

3-
Spring Boot也支持[Log4j](http://logging.apache.org/log4j/1.2)[Log4j 2](http://logging.apache.org/log4j/2.x)作为日志配置,但只有在它们中的某个在classpath下存在的情况。如果你正在使用starter poms进行依赖装配,这意味着你需要排除Logback,然后包含你选择的Log4j版本。如果你不使用starter poms,那除了你选择的Log4j版本外还要提供commons-logging(至少)。
3+
如果[Log4j 2](http://logging.apache.org/log4j/2.x)出现在classpath下,Spring Boot会将其作为日志配置。如果你正在使用starters进行依赖装配,这意味着你需要排除Logback,然后包含log4j 2。如果不使用starters,除了添加Log4j 2,你还需要提供`jcl-over-slf4j`依赖(至少)。
44

5-
最简单的方式可能就是通过starter poms,尽管它需要排除一些依赖,比如,在Maven中:
5+
最简单的方式可能就是通过starters,尽管它需要排除一些依赖,比如,在Maven中:
66
```xml
77
<dependency>
88
<groupId>org.springframework.boot</groupId>
@@ -20,9 +20,8 @@ Spring Boot也支持[Log4j](http://logging.apache.org/log4j/1.2)或[Log4j 2](htt
2020
</dependency>
2121
<dependency>
2222
<groupId>org.springframework.boot</groupId>
23-
<artifactId>spring-boot-starter-log4j</artifactId>
23+
<artifactId>spring-boot-starter-log4j2</artifactId>
2424
</dependency>
2525
```
26-
想要使用Log4j 2,只需要依赖`spring-boot-starter-log4j2`而不是`spring-boot-starter-log4j`
2726

28-
****:使用Log4j各版本的starters都会收集好依赖以满足common logging的要求(比如,Tomcat中使用`java.util.logging`但使用Log4j或 Log4j 2作为输出)具体查看Actuator Log4j或Log4j 2的示例,了解如何将它用于实战。
27+
**** Log4j starters会收集好依赖以满足普通日志记录的需求(比如,Tomcat中使用`java.util.logging`但使用Log4j 2作为输出)具体查看Actuator Log4j 2的示例,了解如何将它用于实战。

0 commit comments

Comments
 (0)