Log4j2找不到我的配置文件 [英] Log4j2 can't find my config file

查看:598
本文介绍了Log4j2找不到我的配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将SLF4J设置为与Log4J2一起使用.但我不断收到此错误:

I'm trying to set up SLF4J to work with Log4J2. But I keep getting this error:

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.

这是我的POM依赖项:

Here are my POM Dependencies:

<properties>
    <log4j.version>2.1</log4j.version>
</properties>

<!-- Logging -->
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.7</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>${log4j.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>${log4j.version}</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-slf4j-impl</artifactId>
    <version>${log4j.version}</version>
</dependency>

我正在使用一个简单的配置进行测试:

I'm using a simple config for testing:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="trace">
    <Appenders>
        <Console name="Console" target="SYSTEM_OUT">
            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
        </Console>
    </Appenders>
    <Loggers>
        <Root level="debug">
            <AppenderRef ref="Console" />
        </Root>
    </Loggers>
</Configuration>

我的log4j2.xml文件位于src/main/resources中.

And my log4j2.xml file is located in src/main/resources.

我不确定还需要检查什么.我也曾尝试将xml文件移至/src目录,但这没有帮助.我想念什么?

I'm not sure what else to check. I've also tried moving the xml file to the /src directory, but it didn't help. What am I missing?

推荐答案

似乎是2.1版中的错误.我将Log4j2回滚到2.0.1版,一切正常.

Appears to be a bug in version 2.1. I rolled back Log4j2 to version 2.0.1 and everything works fine.

这篇关于Log4j2找不到我的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆