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

6

18

I upgraded elasticsearch java client from 2.3 to 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

<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>
Vadnee answered 19/12, 2016 at 5:35 Comment(0)
S
17

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

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

that should fix it

Strafe answered 13/11, 2017 at 13:45 Comment(2)
This fixed it but I do not understand why this worked :|Credulity
@AdityaGupta, this works because the dependency provides a binding from Log4J to SLF4J, so the requirement for a logging implementation is met. You must be using SLF4J already, or adding this dependency by itself wouldn't help.Scalade
L
7

Using newest log4j2 helped me.

<dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.11.1</version>
</dependency>
Laughlin answered 23/8, 2018 at 15:6 Comment(0)
V
2

https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/4

It seems to be a version problem. It works fine with 2.6.2.

Vadnee answered 19/12, 2016 at 9:15 Comment(0)
M
2

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
Maladroit answered 9/11, 2017 at 14:56 Comment(0)
E
1

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)

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
Effable answered 2/3, 2019 at 18:52 Comment(0)
C
0

Add this dependency to the pom.xml

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.2</version>
</dependency>
Coolie answered 16/6, 2020 at 11:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.