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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41216306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 23:14:07  来源:igfitidea点击:

Elasticsearch "StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath."

javaelasticsearchlog4jlog4j2

提问by digsy89

I upgraded elasticsearch java client from 2.3 to 5.1.

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

And this error log continues to appear.

并且这个错误日志继续出现。

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

I'm using log4j2

我正在使用 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>

回答by Abdeslam Elazzam

you need to add properties file as shown here:

你需要添加的属性文件,如在这里

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

rootLogger.level = info
rootLogger.appenderRef.console.ref = console
appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout

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

回答by DariusNica

very late answer, however :) if you don't want to upgrade ES, just add following dependency to pom :

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

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

that should fix it

那应该解决它

回答by stanly

Using newest log4j2helped me.

使用最新的log4j2帮助了我。

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

回答by nantitv

For me following solution worked. Ref- https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/_log4j_2_logger.html( original discussion thread https://github.com/elastic/elasticsearch/pull/25136)

对我来说,以下解决方案有效。参考- 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