添加 logback 日志框架
This commit is contained in:
parent
adfe6eb0ab
commit
86f5244c26
17
pom.xml
17
pom.xml
@ -10,11 +10,22 @@
|
|||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- apache.logging 与 logback 二选一 -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.apache.logging.log4j</groupId>-->
|
||||||
|
<!-- <artifactId>log4j-slf4j-impl</artifactId>-->
|
||||||
|
<!-- <version>2.20.0</version>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!--1.3.x 最后一个支持java1.8 的大版本 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>ch.qos.logback</groupId>
|
||||||
<artifactId>log4j-slf4j-impl</artifactId>
|
<artifactId>logback-classic</artifactId>
|
||||||
<version>2.20.0</version>
|
<version>1.3.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -41,7 +41,7 @@ public class MDCUtil {
|
|||||||
|
|
||||||
public static void putRequestId() {
|
public static void putRequestId() {
|
||||||
try {
|
try {
|
||||||
MDC.put(REQUEST_ID, UUID.randomUUID().toString());
|
MDC.put(REQUEST_ID, UUID.randomUUID().toString().replace("-",""));
|
||||||
} catch (RuntimeException ignored) {}
|
} catch (RuntimeException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
src/main/resources/logback.xml
Normal file
11
src/main/resources/logback.xml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<configuration>
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} %X [%thread] %-5level %logger{36}.%method:%L %kvp %msg%n</pattern>
|
||||||
|
<!-- <pattern>%date{yyyy-MM-dd HH:mm:ss.SSS} %level [%thread] %logger{32}.%method:%L - %msg%n</pattern>-->
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
<root level="debug">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
Loading…
x
Reference in New Issue
Block a user