Elasticsearch“StatusLogger Log4j2找不到日志记录实现。请将log4j-core添加到类路径中。”

时间:2016-12-19 05:35:18

标签: java elasticsearch log4j log4j2

我将elasticsearch java客户端从2.3升级到5.1。

此错误日志将继续显示。

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...

我正在使用log4j2

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.7</version>
</dependency>
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.7</version>
</dependency>

6 个答案:

答案 0 :(得分:7)

很晚才回答,但是:)如果您不想升级ES,只需将以下依赖项添加到pom:

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-to-slf4j</artifactId>
        <version>2.8.2</version>
    </dependency>

应该修复它

答案 1 :(得分:1)

答案 2 :(得分:1)

使用最新的log4j2帮助了我。

<dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.11.1</version>
</dependency>

答案 3 :(得分:0)

您需要添加属性文件,如here所示:

appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout

rootLogger.level = info
rootLogger.appenderRef.console.ref = console

答案 4 :(得分:0)

对我来说,以下解决方案有效。 Ref- https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_log4j_2_logger.html(原始讨论线程https://github.com/elastic/elasticsearch/pull/25136

You need to include Log4j 2 dependencies:

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.11.1</version>
    </dependency>
    And also provide a Log4j 2 configuration file in your classpath. For example, you can add in your src/main/resources project dir a log4j2.properties file like ( I did this): 

    appender.console.type = Console
    appender.console.name = console
    appender.console.layout.type = PatternLayout

    rootLogger.level = info
    rootLogger.appenderRef.console.ref = console

答案 5 :(得分:0)

将此依赖项添加到pom.xml

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.2</version>
</dependency>