# Issue with elastic search 5.0.0 - NoClassDefFoundError: org/apache/logging/log4j/Logger

**URL:** <https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262>\
**Category:** Elasticsearch\
**Created:** [October 28, 2016, 8:36am UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262 "2016-10-28T08:36:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![subbu.nv](https://avatars.discourse-cdn.com/v4/letter/s/439d5e/32.png) [@subbu.nv](https://discuss.elastic.co/u/subbu.nv)\
**Post date:** [October 28, 2016, 8:36am UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/1 "2016-10-28T08:36:47Z")

</div>

Hi,

i am in the process of converting the elastic search version from 2.x to 5.0.0.  
i am seeing the below error when i try to initialize the client.  
client = new PreBuiltTransportClient(settings);

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger  
at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:105)  
at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:72)  
at org.elasticsearch.common.component.AbstractComponent.(AbstractComponent.java:37)  
at org.elasticsearch.plugins.PluginsService.(PluginsService.java:110)  
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:81)  
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:106)  
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:228)  
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:69)  
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:65)

am having the below dependencies in pom.xml

```
                <dependency>
		<groupId>org.elasticsearch</groupId>
		<artifactId>elasticsearch</artifactId>
		<version>5.0.0</version>
	</dependency>
	<dependency>
                <groupId>org.elasticsearch.client</groupId>
                   <artifactId>transport</artifactId>
             <version>5.0.0</version>
         </dependency>

```

please help.

thanks

---

<div class="post-metadata">

**Author:** ![ywelsch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ywelsch/32/7751_2.png) [@ywelsch](https://discuss.elastic.co/u/ywelsch)\
**Post date:** [October 28, 2016, 9:12am UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/2 "2016-10-28T09:12:10Z")

</div>

You have to add logging dependencies:

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

```

---

<div class="post-metadata">

**Author:** ![Fabrizio\_Fortino](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fabrizio_fortino/32/1719_2.png) [@Fabrizio\_Fortino](https://discuss.elastic.co/u/Fabrizio_Fortino)\
**Post date:** [October 28, 2016, 9:13am UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/3 "2016-10-28T09:13:34Z")

</div>

[https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking\_50\_java\_api\_changes.html#\_elasticsearch\_will\_no\_longer\_detect\_logging\_implementations](https://www.elastic.co/guide/en/elasticsearch/reference/5.0/breaking_50_java_api_changes.html#_elasticsearch_will_no_longer_detect_logging_implementations)

With ES 5 you have to explicitly include Log4J 2 as dependency in your pom.

---

<div class="post-metadata">

**Author:** ![speedyroute](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/speedyroute/32/12906_2.png) [@speedyroute](https://discuss.elastic.co/u/speedyroute)\
**Post date:** [November 2, 2016, 11:59am UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/4 "2016-11-02T11:59:30Z")

</div>

Managed to get Logging to work with sbt Scala over slf4j with these deps:

```auto
  "org.slf4j" % "slf4j-simple" % "1.7.21",
  "org.apache.logging.log4j" % "log4j-api" % "2.6.2",
  "org.apache.logging.log4j" % "log4j-to-slf4j" % "2.6.2",

```

Note log4j 2.7 does not seem to work with ElasticSearch 5.0.0

---

<div class="post-metadata">

**Author:** ![mvenkat\_in](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@mvenkat\_in](https://discuss.elastic.co/u/mvenkat_in)\
**Post date:** [November 3, 2016, 2:37pm UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/5 "2016-11-03T14:37:06Z")

</div>

Yes. I faced the same issue with Log4j 2.7.

I followed your steps and compiled successfully.

---

<div class="post-metadata">

**Author:** ![ugxzl123](https://avatars.discourse-cdn.com/v4/letter/u/85e7bf/32.png) [@ugxzl123](https://discuss.elastic.co/u/ugxzl123)\
**Post date:** [February 6, 2017, 10:35am UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/6 "2017-02-06T10:35:04Z")

</div>

Same issue ，i use slf4j, resovled by add  
  
org.apache.logging.log4j  
log4j-to-slf4j  
2.6.2  
  
  
org.apache.logging.log4j  
log4j-api  
  
  
org.apache.logging.log4j  
log4j-core  
  
please refer [https://logging.apache.org/log4j/2.0/log4j-slf4j-impl/index.html](https://logging.apache.org/log4j/2.0/log4j-slf4j-impl/index.html)

---

<div class="post-metadata">

**Author:** ![nanothermite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nanothermite/32/15956_2.png) [@nanothermite](https://discuss.elastic.co/u/nanothermite)\
**Post date:** [March 16, 2017, 9:17pm UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/7 "2017-03-16T21:17:56Z")

</div>

None of the combinations above worked for me. I have tried up to this version of artifacts:

"org.elasticsearch" % "elasticsearch" % "5.2.1", // "1.7.1",  
"org.elasticsearch.client" % "transport" % "5.2.1", // "1.7.1",  
//"org.apache.logging.log4j" % "log4j-to-slf4j" % "2.8",  
"org.slf4j" % "slf4j-simple" % "1.7.24",  
"org.apache.logging.log4j" % "log4j-api" % "2.8.1",  
"org.apache.logging.log4j" % "log4j-core" % "2.8.1",

Any suggestions?

---

<div class="post-metadata">

**Author:** ![nanothermite](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nanothermite/32/15956_2.png) [@nanothermite](https://discuss.elastic.co/u/nanothermite)\
**Post date:** [March 16, 2017, 9:33pm UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/8 "2017-03-16T21:33:40Z")

</div>

For the win:

"org.elasticsearch" % "elasticsearch" % "5.2.1", // "1.7.1",  
//"org.elasticsearch.client" % "transport" % "5.2.1", // "1.7.1",  
"org.apache.logging.log4j" % "log4j-to-slf4j" % "2.8",  
//"org.slf4j" % "slf4j-simple" % "1.7.24",  
"org.apache.logging.log4j" % "log4j-api" % "2.8.1",  
"org.apache.logging.log4j" % "log4j-core" % "2.8.1",

The maven dependencies in this thread helped:

> <https://github.com/elastic/elasticsearch/issues/19415>

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:02pm UTC](https://discuss.elastic.co/t/issue-with-elastic-search-5-0-0-noclassdeffounderror-org-apache-logging-log4j-logger/64262/9 "2017-07-05T22:02:08Z")

</div>


