zoukankan      html  css  js  c++  java
  • springboot项目报错解决:ERROR StatusLogger No Log4j 2 configuration file found

    springboot项目报错:ERROR StatusLogger No Log4j 2 configuration file found

    问题描述

    spring boot项目,识别不了log4j2.yml配置文件,报如下错误:

    ERROR StatusLogger No Log4j 2 configuration file found. Using default configuration (logging only errors to the console), or user programmatically provided configurations. Set system property 'log4j2.debug' to show Log4j 2 internal initialization logging. See https://logging.apache.org/log4j/2.x/manual/configuration.html for instructions on how to configure Log4j 2

    很明显,错误显示找不到log4j2的配置文件,但是resources目标下,确定是有该文件的。

    初步判断是依赖问题,导致没有读取到配置文件。

    解决方案:

    <dependencies>
    		<dependency>
        		 <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter</artifactId>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
           
            <!-- 配置 log4j2 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-log4j2</artifactId>
            </dependency>
            <!-- 加上这个才能辨认到log4j2.yml文件 -->
            <dependency>
                <groupId>com.fasterxml.jackson.dataformat</groupId>
                <artifactId>jackson-dataformat-yaml</artifactId>
            </dependency>
           <!-- 加上这个,上面那个包才能正常工作 -->
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${jackson-databind-version}</version>
            </dependency>
    </dependencies>
    

    总结:

    1、首先引入spring-boot包,去掉其中默认的logback包

    2、引入spring-boot-starter-log4j2包,配置log4j2

    3、加上jackson-databind和jackson-dataformat-yaml才能正常识别log4j2.yml文件

  • 相关阅读:
    jmeter响应结果乱码问题
    JMeter 脚本请求错误 HTTP Status 415 的解决
    使用fiddler进行genymotion安卓虚拟机手机抓包
    Android模拟器Genymotion安装使用教程详解
    java基础-数组
    Qt类继承图
    Linux-磁盘管理小结
    User and User Groups in Linux
    Qt5.3编译错误——call of overloaded ‘max(int int)’is ambiguous
    i++ and ++i efficiency
  • 原文地址:https://www.cnblogs.com/wchaos/p/14441419.html
Copyright © 2011-2022 走看看