springboot依赖中默认引入spring-boot-starter-logging,若要使用log4j2日志框架,则需要先将spring-boot-starter-logging排除。
方法:
在依赖关系图中找到spring-boot-starter-logging,单击右键选择exclude将其排除出去。
pom文件中引入:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-log4j2</artifactId> </dependency>
如此就可以使用log4j2日志框架了。