spinrgBoot集成log4j2框架出现多jar错误

springBoot框架集成log4j2框架时,使用idea开发工具,修改pom.xml文件如下:


        
            org.springframework.boot
            spring-boot-starter-web
            
               
                   org.springframework.boot
                   spring.boot.starter-logging
               
           
        
        
        
            org.springframework.boot
            spring-boot-starter-log4j2
        
运行程序出现如下错误:

Logging system failed to initialize using configuration from 'classpath:log4j2.xml'
java.lang.IllegalStateException: Logback configuration error detected: 
ERROR in ch.qos.logback.core.joran.spi.Interpreter@4:13 - no applicable action for [appenders], current ElementPath is [configuration]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@6:47 - no applicable action for [Console], current ElementPath is [configuration[Console]]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@8:70 - no applicable action for [ThresholdFilter], current ElementPath is [configurationConsole]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@10:86 - no applicable action for [PatternLayout], current ElementPath is [configurationConsole]
ERROR in ch.qos.logback.core.joran.spi.Interpreter@14:59 - no applicable action for [File], current ElementPath is [configuration[File]]
错误原因:

引用jar时引用了多个logback的框架,由于idea开发工具未根据pom.xml的配置自动配置依赖,未去除之前的log4j的依赖,导致无法解析节点信息。

解决办法:

在pom.xml文件中右击选择Diagrams,查看依赖图,找到spring.boot.starter-logging依赖,删除即可。




你可能感兴趣的:(#,Log4j2,log4j2)