# slf4j-log4j jar required?

**URL:** <https://discuss.elastic.co/t/slf4j-log4j-jar-required/3459>\
**Category:** Elasticsearch\
**Created:** [October 19, 2010, 11:59pm UTC](https://discuss.elastic.co/t/slf4j-log4j-jar-required/3459 "2010-10-19T23:59:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Diptamay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/diptamay/32/2805_2.png) [@Diptamay](https://discuss.elastic.co/u/Diptamay)\
**Post date:** [October 19, 2010, 11:59pm UTC](https://discuss.elastic.co/t/slf4j-log4j-jar-required/3459/1 "2010-10-19T23:59:50Z")

</div>

Hi

This is probably a silly question. But so far I have always used ES's  
http endpoint to do my searching. Now that I am trying to use the java  
api, I dropped in the elasticsearch-0.12.0.jar into my classpath and  
expected my tests to run which is just creating a TransportClient at  
the moment.

However, slf4j starts giving errors using Guice injection. Start of  
the error stack trace bloew is

[BF-INFO] Source Directory: '/Users/sanyal/Documents/workspace/  
mlbam/svn/cms/search/client/test/java'  
[BF-INFO] Include: '**/\*'  
[BF-INFO] Exclude: ' **/CVS/**'  
[BF-INFO] Exclude: '**/.svn/\*\*'  
[javac] Compiling 1 source file to /Users/sanyal/Documents/  
workspace/mlbam/svn/cms/search/client/build/test/java/classes  
[junit] Running com.bamnetworks.cms.search.test.ESClientTest  
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167  
sec  
[junit] Testsuite: com.bamnetworks.cms.search.test.ESClientTest  
[junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167  
sec

```
[junit] ------------- Standard Error -----------------
[junit] SLF4J: Failed to load class

```

"org.slf4j.impl.StaticLoggerBinder".  
[junit] SLF4J: See [http://www.slf4j.org/codes.html#StaticLoggerBinder](http://www.slf4j.org/codes.html#StaticLoggerBinder)  
for further details.  
[junit] ------------- ---------------- ---------------  
[junit] Testcase:  
testGetESEndpoints(com.bamnetworks.cms.search.test.ESClientTest):  
Caused an ERROR  
[junit] Guice creation errors:

```
[junit] 1) Error injecting constructor,

```

java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be  
successfully initialized. See also [http://www.slf4j.org/codes.html#unsuccessfulInit](http://www.slf4j.org/codes.html#unsuccessfulInit)  
[junit] at  
org.elasticsearch.common.network.NetworkService.(NetworkService.java:  
63)  
[junit] while locating  
org.elasticsearch.common.network.NetworkService  
[junit] Caused by: java.lang.IllegalStateException:  
org.slf4j.LoggerFactory could not be successfully initialized. See  
also [http://www.slf4j.org/codes.html#unsuccessfulInit](http://www.slf4j.org/codes.html#unsuccessfulInit)  
[junit] at  
org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:282)  
[junit] at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:  
248)  
[junit] at  
org.elasticsearch.common.logging.slf4j.Slf4jESLoggerFactory.newInstance(Slf4jESLoggerFactory.java:  
32)  
[junit] at  
org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:  
60)  
[junit] at  
org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:142)  
[junit] at  
org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:105)

After dropping in the slf4j-log4j jar, which I downloaded separately,  
this starts working. I don't see any dependency of this in the ES  
maven poms or even in the ES distribution download itself.

Any idea what could be the issue here?

As a side note, do I need logging.yml and elasticsearch.yml in my  
classpath for the ES client to work properly.

Thanks  
Diptamay

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 20, 2010, 12:07am UTC](https://discuss.elastic.co/t/slf4j-log4j-jar-required/3459/2 "2010-10-20T00:07:02Z")

</div>

Hi,

You don't need to slf4j-log4j bridge, but if slf4j jar (not the bridge,  
the API) is in the classpath, it will be used by elasticsearch as the  
logging framework. Do you have it in the classpath?

You don't need the yml configuration files.

-shay.banon

On Wed, Oct 20, 2010 at 1:59 AM, diptamay [diptamay@gmail.com](mailto:diptamay@gmail.com) wrote:

> Hi
> 
> This is probably a silly question. But so far I have always used ES's  
> http endpoint to do my searching. Now that I am trying to use the java  
> api, I dropped in the elasticsearch-0.12.0.jar into my classpath and  
> expected my tests to run which is just creating a TransportClient at  
> the moment.
> 
> However, slf4j starts giving errors using Guice injection. Start of  
> the error stack trace bloew is
> 
> [BF-INFO] Source Directory: '/Users/sanyal/Documents/workspace/  
> mlbam/svn/cms/search/client/test/java'  
> [BF-INFO] Include: '**/\*'  
> [BF-INFO] Exclude: ' **/CVS/**'  
> [BF-INFO] Exclude: '**/.svn/\*\*'  
> [javac] Compiling 1 source file to /Users/sanyal/Documents/  
> workspace/mlbam/svn/cms/search/client/build/test/java/classes  
> [junit] Running com.bamnetworks.cms.search.test.ESClientTest  
> [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167  
> sec  
> [junit] Testsuite: com.bamnetworks.cms.search.test.ESClientTest  
> [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167  
> sec
> 
> [junit] ------------- Standard Error -----------------  
> [junit] SLF4J: Failed to load class  
> "org.slf4j.impl.StaticLoggerBinder".  
> [junit] SLF4J: See [SLF4J Error Codes](http://www.slf4j.org/codes.html#StaticLoggerBinder)  
> for further details.  
> [junit] ------------- ---------------- ---------------  
> [junit] Testcase:  
> testGetESEndpoints(com.bamnetworks.cms.search.test.ESClientTest):  
> Caused an ERROR  
> [junit] Guice creation errors:
> 
> [junit] 1) Error injecting constructor,  
> java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be  
> successfully initialized. See also  
> [SLF4J Error Codes](http://www.slf4j.org/codes.html#unsuccessfulInit)  
> [junit] at  
> org.elasticsearch.common.network.NetworkService.(NetworkService.java:  
> 63)  
> [junit] while locating  
> org.elasticsearch.common.network.NetworkService  
> [junit] Caused by: java.lang.IllegalStateException:  
> org.slf4j.LoggerFactory could not be successfully initialized. See  
> also [SLF4J Error Codes](http://www.slf4j.org/codes.html#unsuccessfulInit)  
> [junit] at  
> org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:282)  
> [junit] at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:  
> 248)  
> [junit] at
> 
> org.elasticsearch.common.logging.slf4j.Slf4jESLoggerFactory.newInstance(Slf4jESLoggerFactory.java:  
> 32)  
> [junit] at
> 
> org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.java:  
> 60)  
> [junit] at  
> org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:142)  
> [junit] at  
> org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:105)
> 
> After dropping in the slf4j-log4j jar, which I downloaded separately,  
> this starts working. I don't see any dependency of this in the ES  
> maven poms or even in the ES distribution download itself.
> 
> Any idea what could be the issue here?
> 
> As a side note, do I need logging.yml and elasticsearch.yml in my  
> classpath for the ES client to work properly.
> 
> Thanks  
> Diptamay

---

<div class="post-metadata">

**Author:** ![Diptamay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/diptamay/32/2805_2.png) [@Diptamay](https://discuss.elastic.co/u/Diptamay)\
**Post date:** [October 20, 2010, 5:04am UTC](https://discuss.elastic.co/t/slf4j-log4j-jar-required/3459/3 "2010-10-20T05:04:36Z")

</div>

Hi Shay

Thanks for the quick reply.

I see the problem now. Some project that my build is depending on, is  
pulling in the slf4j api jar without adding a dependency for the slf4j  
log4j bridge. Need to pull up that project owner for this.

If the logging.yml file is not included then where would the logging  
output go? Would it go to console or Would it look at the log4j props  
which I am including as part for my codebase?

Btw, I love the concept of the script fields and I just happened to  
note it yesterday. It has already made my life a lot easier, apart  
from the fact ES is really kick-ass. I have successfully stalled the  
very discussion of Riak search as and when people brought it up. Not  
sure where you have had a chance to look at Riak-ES integration (must  
like the CouchDB river). Any plans?

Thanks  
Diptamay

On Oct 19, 8:07 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Hi,
> 
> You don't need to slf4j-log4j bridge, but if slf4j jar (not the bridge,  
> the API) is in the classpath, it will be used by elasticsearch as the  
> logging framework. Do you have it in the classpath?
> 
> You don't need the yml configuration files.
> 
> -shay.banon
> 
> On Wed, Oct 20, 2010 at 1:59 AM, diptamay [dipta...@gmail.com](mailto:dipta...@gmail.com) wrote:
> 
> > Hi
> 
> > This is probably a silly question. But so far I have always used ES's  
> > http endpoint to do my searching. Now that I am trying to use the java  
> > api, I dropped in the elasticsearch-0.12.0.jar into my classpath and  
> > expected my tests to run which is just creating a TransportClient at  
> > the moment.
> 
> > However, slf4j starts giving errors using Guice injection. Start of  
> > the error stack trace bloew is
> 
> > [BF-INFO] Source Directory: '/Users/sanyal/Documents/workspace/  
> > mlbam/svn/cms/search/client/test/java'  
> > [BF-INFO] Include: '**/\*'  
> > [BF-INFO] Exclude: ' **/CVS/**'  
> > [BF-INFO] Exclude: '**/.svn/\*\*'  
> > [javac] Compiling 1 source file to /Users/sanyal/Documents/  
> > workspace/mlbam/svn/cms/search/client/build/test/java/classes  
> > [junit] Running com.bamnetworks.cms.search.test.ESClientTest  
> > [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167  
> > sec  
> > [junit] Testsuite: com.bamnetworks.cms.search.test.ESClientTest  
> > [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167  
> > sec
> 
> > [junit] ------------- Standard Error -----------------  
> > [junit] SLF4J: Failed to load class  
> > "org.slf4j.impl.StaticLoggerBinder".  
> > [junit] SLF4J: Seehttp://www.slf4j.org/codes.html#StaticLoggerBinder  
> > for further details.  
> > [junit] ------------- ---------------- ---------------  
> > [junit] Testcase:  
> > testGetESEndpoints(com.bamnetworks.cms.search.test.ESClientTest):  
> > Caused an ERROR  
> > [junit] Guice creation errors:
> 
> > [junit] 1) Error injecting constructor,  
> > java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be  
> > successfully initialized. See also  
> > [SLF4J Error Codes](http://www.slf4j.org/codes.html#unsuccessfulInit)  
> > [junit] at  
> > org.elasticsearch.common.network.NetworkService.(NetworkService.java:  
> > 63)  
> > [junit] while locating  
> > org.elasticsearch.common.network.NetworkService  
> > [junit] Caused by: java.lang.IllegalStateException:  
> > org.slf4j.LoggerFactory could not be successfully initialized. See  
> > alsohttp://www.slf4j.org/codes.html#unsuccessfulInit  
> > [junit] at  
> > org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:282)  
> > [junit] at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:  
> > 248)  
> > [junit] at
> 
> > org.elasticsearch.common.logging.slf4j.Slf4jESLoggerFactory.newInstance(Slf 4jESLoggerFactory.java:  
> > 32)  
> > [junit] at
> 
> > org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory. java:  
> > 60)  
> > [junit] at  
> > org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:142)  
> > [junit] at  
> > org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:105)
> 
> > After dropping in the slf4j-log4j jar, which I downloaded separately,  
> > this starts working. I don't see any dependency of this in the ES  
> > maven poms or even in the ES distribution download itself.
> 
> > Any idea what could be the issue here?
> 
> > As a side note, do I need logging.yml and elasticsearch.yml in my  
> > classpath for the ES client to work properly.
> 
> > Thanks  
> > Diptamay

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 20, 2010, 8:26am UTC](https://discuss.elastic.co/t/slf4j-log4j-jar-required/3459/4 "2010-10-20T08:26:31Z")

</div>

On Wed, Oct 20, 2010 at 7:04 AM, diptamay [diptamay@gmail.com](mailto:diptamay@gmail.com) wrote:

> Hi Shay
> 
> Thanks for the quick reply.
> 
> I see the problem now. Some project that my build is depending on, is  
> pulling in the slf4j api jar without adding a dependency for the slf4j  
> log4j bridge. Need to pull up that project owner for this.
> 
> If the logging.yml file is not included then where would the logging  
> output go? Would it go to console or Would it look at the log4j props  
> which I am including as part for my codebase?

It will be based on the loggig you decide to you, and how you configure it.  
It delegates when embedded.

> Btw, I love the concept of the script fields and I just happened to  
> note it yesterday. It has already made my life a lot easier, apart  
> from the fact ES is really kick-ass. I have successfully stalled the  
> very discussion of Riak search as and when people brought it up. Not  
> sure where you have had a chance to look at Riak-ES integration (must  
> like the CouchDB river). Any plans?

First, I don't really think you need to stall testing Riak search, it can be  
tested. There are big differences between the two, but the most important  
one is that it does not come close in terms of feature set compared to  
elasticsearch (I suspect, based on the architectural decision made by riak  
search, that performance will also be very different, but that requires  
verifying).

Riak-ES integration is possible. I am not familiar with Riak having a  
\_changes stream similar to elasticsearch, so the closest I can think is post  
commit hooks, but thats on Riak side and not a River... .

> Thanks  
> Diptamay
> 
> On Oct 19, 8:07 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Hi,
> > 
> > You don't need to slf4j-log4j bridge, but if slf4j jar (not the bridge,  
> > the API) is in the classpath, it will be used by elasticsearch as the  
> > logging framework. Do you have it in the classpath?
> > 
> > You don't need the yml configuration files.
> > 
> > -shay.banon
> > 
> > On Wed, Oct 20, 2010 at 1:59 AM, diptamay [dipta...@gmail.com](mailto:dipta...@gmail.com) wrote:
> > 
> > > Hi
> > 
> > > This is probably a silly question. But so far I have always used ES's  
> > > http endpoint to do my searching. Now that I am trying to use the java  
> > > api, I dropped in the elasticsearch-0.12.0.jar into my classpath and  
> > > expected my tests to run which is just creating a TransportClient at  
> > > the moment.
> > 
> > > However, slf4j starts giving errors using Guice injection. Start of  
> > > the error stack trace bloew is
> > 
> > > [BF-INFO] Source Directory: '/Users/sanyal/Documents/workspace/  
> > > mlbam/svn/cms/search/client/test/java'  
> > > [BF-INFO] Include: '**/\*'  
> > > [BF-INFO] Exclude: ' **/CVS/**'  
> > > [BF-INFO] Exclude: '**/.svn/\*\*'  
> > > [javac] Compiling 1 source file to /Users/sanyal/Documents/  
> > > workspace/mlbam/svn/cms/search/client/build/test/java/classes  
> > > [junit] Running com.bamnetworks.cms.search.test.ESClientTest  
> > > [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167  
> > > sec  
> > > [junit] Testsuite: com.bamnetworks.cms.search.test.ESClientTest  
> > > [junit] Tests run: 1, Failures: 0, Errors: 1, Time elapsed: 4.167  
> > > sec
> > 
> > > [junit] ------------- Standard Error -----------------  
> > > [junit] SLF4J: Failed to load class  
> > > "org.slf4j.impl.StaticLoggerBinder".  
> > > [junit] SLF4J: Seehttp://  
> > > [SLF4J Error Codes](http://www.slf4j.org/codes.html#StaticLoggerBinder)  
> > > for further details.  
> > > [junit] ------------- ---------------- ---------------  
> > > [junit] Testcase:  
> > > testGetESEndpoints(com.bamnetworks.cms.search.test.ESClientTest):  
> > > Caused an ERROR  
> > > [junit] Guice creation errors:
> > 
> > > [junit] 1) Error injecting constructor,  
> > > java.lang.IllegalStateException: org.slf4j.LoggerFactory could not be  
> > > successfully initialized. See also  
> > > [SLF4J Error Codes](http://www.slf4j.org/codes.html#unsuccessfulInit)  
> > > [junit] at
> 
> org.elasticsearch.common.network.NetworkService.(NetworkService.java:
> 
> > > 1. 
> > > 
> > > [junit] while locating  
> > > org.elasticsearch.common.network.NetworkService  
> > > [junit] Caused by: java.lang.IllegalStateException:  
> > > org.slf4j.LoggerFactory could not be successfully initialized. See  
> > > alsohttp://www.slf4j.org/codes.html#unsuccessfulInit  
> > > [junit] at  
> > > org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:282)  
> > > [junit] at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:  
> > > 248)  
> > > [junit] at
> > 
> > >
> 
> org.elasticsearch.common.logging.slf4j.Slf4jESLoggerFactory.newInstance(Slf  
> 4jESLoggerFactory.java:
> 
> > > 1. 
> > > 
> > > [junit] at
> > 
> > >
> 
> org.elasticsearch.common.logging.ESLoggerFactory.getLogger(ESLoggerFactory.  
> java:
> 
> > > 1. 
> > > 
> > > [junit] at  
> > > org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:142)  
> > > [junit] at  
> > > org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:105)
> > 
> > > After dropping in the slf4j-log4j jar, which I downloaded separately,  
> > > this starts working. I don't see any dependency of this in the ES  
> > > maven poms or even in the ES distribution download itself.
> > 
> > > Any idea what could be the issue here?
> > 
> > > As a side note, do I need logging.yml and elasticsearch.yml in my  
> > > classpath for the ES client to work properly.
> > 
> > > Thanks  
> > > Diptamay

---

<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 6, 2017, 4:17am UTC](https://discuss.elastic.co/t/slf4j-log4j-jar-required/3459/5 "2017-07-06T04:17:44Z")

</div>


