1、排除 SpringBoot 默认的 logback 依赖

    org.springframework.boot    spring-boot-starter-web                        org.springframework.boot            spring-boot-starter-logging            

2、添加 log4j2 的依赖

    org.springframework.boot    spring-boot-starter-log4j2

3、在 resources 目录下新建一个 log4j2-spring.xml 的日志配置文件。

一般情况下,这样就能在 SpringBoot 里面使用 log4j2 了。 此外还要做一些完善。