本文介绍了使用log4j2进行Spring-Boot日志记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 spring-boot-starter
,并希望配置 log4j2.xml
来记录异步+不同内容与不同的日志文件。
I'm using spring-boot-starter
, and would like to configure log4j2.xml
to log asynchron + different content to different logfiles.
我创建了log4j2文件,但是 Spring
仍然使用spring-boot默认值日志记录。如何切换日志?
I created the log4j2 file, but Spring
still uses the spring-boot default logging. How can I switch the logging?
推荐答案
我有更好的方法:
-
排除logback记录器:
Exclude logback logger:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
添加log4j2启动启动器:
Add log4j2 boot starter:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
来源:
享受!
这篇关于使用log4j2进行Spring-Boot日志记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!