SpringBoot2.7.x下log4j报错ERROR StatusLogger Log4j2 could not find a logging implementation问题解决

2022-05-26 632点热度 0人点赞 0条评论

问题描述

今天升级了Spring项目的SpringBoot版本(2.5.x->2.7.x)再次启动后,console日志打印出红色的:

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

另外发现除了log.error能显示外,log.warn log.info都无法显示出来了。

问题解决

我的SpringBoot项目时候的是log4j作为日志系统的,如何配置详见:https://blog.terrynow.com/2021/07/27/springboot-config-log4j-pattern-and-split/,之前引用的是:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-log4j</artifactId>
    <version>1.3.8.RELEASE</version>
</dependency>

升级SpringBoot就不行,需要多引入log4j-core(不用担心,这个版本的lo4j2是没有安全漏洞的!)

maven依赖log4j-core,具体:pom.xml再增加如下依赖即可

dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.17.2</version>
</dependency>

 

admin

这个人很懒,什么都没留下

文章评论

您需要 登录 之后才可以评论