Log:logback.xml配置
Maven 管理的项目,在src/main/resources
下新建logback.xml
文件。
- logback.xml配置
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<configuration scan="true" scanPeriod="1 seconds" debug="false">
<timestamp key="bySecond" datePattern="yyyyMMdd'T'HHmmss" />
<contextName>${bySecond}</contextName>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<!-- <pattern>%-4relative [%thread] %-5level %logger{35} - %msg %n</pattern> -->
<pattern>logbak: %d{HH:mm:ss.sss} %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="org.springframework.web" level="DEBUG"/>
<root level="info">
<appender-ref ref="console"/>
</root>
</configuration> - 在pom.xml导入logback依赖包
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19<properties>
<logback.version>1.2.3</logback.version>
</properties>
<!-- logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-access</artifactId>
<version>${logback.version}</version>
</dependency>
Log:logback.xml配置