1、抑制原生日志
pom.xml
<!-- springboot框架web项目起步依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<!-- 抑制原生日志 -->
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
2、加入依赖
pom.xml
<!-- log4j日志 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
3、添加配置文件
log4j.properties
#控制日志级别,在哪里输出Output pattern : date [thread] priority category - message FATAL 0 ERROR 3 WARN 4 INF