Skip to content

Commit fc1f39b

Browse files
committed
使用log4j2记录日志
1 parent 0dd9c71 commit fc1f39b

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

2.x/chapter8-2/pom.xml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@
2424
<dependency>
2525
<groupId>org.springframework.boot</groupId>
2626
<artifactId>spring-boot-starter-web</artifactId>
27+
<exclusions>
28+
<exclusion>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-logging</artifactId>
31+
</exclusion>
32+
</exclusions>
2733
</dependency>
2834

29-
<!-- <dependency>-->
30-
<!-- <groupId>org.springframework.boot</groupId>-->
31-
<!-- <artifactId>spring-boot-starter-log4j2</artifactId>-->
32-
<!-- </dependency>-->
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-log4j2</artifactId>
38+
</dependency>
3339

3440
<dependency>
3541
<groupId>org.springframework.boot</groupId>
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,2 @@
1-
debug=true
21

3-
spring.output.ansi.enabled=detect
4-
5-
logging.file.name=run.log
6-
logging.file.path=./
7-
8-
logging.level.com.didispace=debug
9-
10-
logging.logback.rollingpolicy.clean-history-on-start=false
11-
logging.logback.rollingpolicy.file-name-pattern=
12-
logging.logback.rollingpolicy.max-history=7
13-
logging.logback.rollingpolicy.max-file-size=10MB
14-
logging.logback.rollingpolicy.total-size-cap=0B
2+
logging.config=classpath:log4j2.xml
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Configuration status="INFO">
3+
<Appenders>
4+
<Console name="Console" target="SYSTEM_OUT">
5+
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
6+
</Console>
7+
</Appenders>
8+
<Loggers>
9+
<Root level="INFO">
10+
<AppenderRef ref="Console"/>
11+
</Root>
12+
</Loggers>
13+
</Configuration>

0 commit comments

Comments
 (0)