main ERROR processing element appender configuration: null:CLASS_NOT_FOUND【解决方法】

今天爱分享给大家带来main ERROR processing element appender configuration: null:CLASS_NOT_FOUND【解决方法】,希望能够帮助到大家。
问题场景
springboot框架项目,为了兼容老项目,将日志系统改造为log4j。启动项目之后,日志报错,提示如下:


2020-12-24 15:01:08,452 main ERROR Error processing element appender ([configuration: null]): CLASS_NOT_FOUND
2020-12-24 15:01:08,453 main ERROR Unknown object "property" of type org.apache.logging.log4j.core.config.Property is ignored: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"].
2020-12-24 15:01:08,454 main ERROR Unknown object "property" of type org.apache.logging.log4j.core.config.Property is ignored: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"].
2020-12-24 15:01:08,456 main ERROR Unknown object "root" of type org.apache.logging.log4j.core.config.LoggerConfig is ignored: try nesting it inside one of: ["Appenders", "Loggers", "Properties", "Scripts", "CustomLevels"].

问题原因
因为项目是微服务项目,使用了配置中心进行项目配置管控。其中,common默认的日志文件是logback.xml。而项目移除了logback的相关依赖,引入了log4j的相关依赖。但是忘记修改日志文件路径,导致了还是默认的日志文件。而logback文件使用的语法是logback的,与log4j不符。导致项目启动之后,按照配置读取报错,导致日志输出异常。

解决方案
设置logging.config为classpath:log4j2.xml,重新启动项目;

人已赞赏
Java

unix时间戳的转换 Java实现【附代码】

2020-12-13 23:37:13

Java

o.s.b.a.amqp.RabbitHealthIndicator:Rabbit health check failed【解决方法】

2020-12-30 22:12:44