Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
like image 840
digsy89 Avatar asked Dec 19 '16 05:12

digsy89


People also ask

How to resolve log4j2 error statuslogger could not find a logging implementation?

ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console... I resolved it by excluding log4j-api from elasticsearch dependency, but on the other hand, I have got this error: Cause: java.lang.ClassNotFoundException: org.apache.logging.log4j.Logger

What version of log4j-api does Elasticsearch use?

In dependency analyzer, I found that elasticsearch uses log4j-api 2.11.1 <dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>6.7.0</version> </dependency> ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath.

How to add Log4j 2 to your project?

You need to also include Log4j 2 dependencies: 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:


2 Answers

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

like image 163
DariusNica Avatar answered Sep 20 '22 13:09

DariusNica


Using newest log4j2 helped me.

<dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.11.1</version>
</dependency>
like image 24
stanly Avatar answered Sep 16 '22 13:09

stanly