栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Logging system failed to initialize using configuration from ‘classpath:log4j2.xml

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Logging system failed to initialize using configuration from ‘classpath:log4j2.xml

 引用log4j2报错:Dependency 'org.springframework.boot:spring-boot-starter-log4j2:' not found

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

一开始是用上面引用,但是项目提示找不到依赖库。然后参考别人改成以下方式。添加成功之后,运行又报错。

   
        
            org.apache.logging.log4j
            log4j-api
            2.17.0
        
        
            org.apache.logging.log4j
            log4j-core
            2.17.0
        
        
            org.apache.logging.log4j
            log4j-slf4j-impl
            2.17.0
        

报错信息:

在IDEA中,springboot的项目,引入log4j2日志配置时报错:
Logging system failed to initialize using configuration from 'classpath:log4j2.xml'
java.lang.IllegalStateException: Logback configuration error detected: 

分析
配置log4j2.xml文件没有少。

 参考网上说明,主要是sprinpboot原来logback包存在导致冲突,检查包含lib里确实是有logback包。

参考网上的配置,更新pom.xml,更新完成之后,清除一下缓存,重新同步maven相关配置。即可解决问题。

pom.xml 整个源码配置如下



    4.0.0

    org.gtk
    mbblibser
    1.0-SNAPSHOT
    
        
            
                org.apache.maven.plugins
                maven-compiler-plugin
                
                    1.8
                    1.8
                
            
        
    

    
        
            org.springframework.boot
            spring-boot-starter-web
            2.5.6
            
                
                    org.springframework.boot
                    spring-boot-starter-logging
                
                
                    org.apache.logging.log4j
                    log4j-core
                
                
                    org.apache.logging.log4j
                    log4j-api
                
                
                    org.apache.logging.log4j
                    log4j-slf4j-impl
                

            
        

        
            com.google.collections
            google-collections
            1.0
        



        
        
            org.apache.logging.log4j
            log4j-api
            2.17.0
        
        
            org.apache.logging.log4j
            log4j-core
            2.17.0
        
        
            org.apache.logging.log4j
            log4j-slf4j-impl
            2.17.0
        

    


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/973293.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号