# How do i enable logging for elasticsearch java client

**URL:** <https://discuss.elastic.co/t/how-do-i-enable-logging-for-elasticsearch-java-client/22655>\
**Category:** Elasticsearch\
**Created:** [March 13, 2015, 2:27pm UTC](https://discuss.elastic.co/t/how-do-i-enable-logging-for-elasticsearch-java-client/22655 "2015-03-13T14:27:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sunil](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@Sunil](https://discuss.elastic.co/u/Sunil)\
**Post date:** [March 13, 2015, 2:27pm UTC](https://discuss.elastic.co/t/how-do-i-enable-logging-for-elasticsearch-java-client/22655/1 "2015-03-13T14:27:48Z")

</div>

I built this standalone Java application that is connecting to  
elasticSearch using Transport client on my local machine. I am trying to  
figure out how to enable logging in it (This is to help me debug a wiered  
streamcorrupexception that i am getting in my production cluster) but not  
able to get it working. Can some one help

This is how my log4j.xml looks like [log4j.xml](https://gist.github.com/1023a89b8f40f6e43fe9.git) and  
this is how my pom.xml file for application looks like [pom.xml](https://gist.github.com/ac1a373e8c043181f474.git). My  
java client does create simple TransportClient and executes match all query  
on it, the query is working ok. But i dont see much logs being created. I  
also tried setting --Des.logger.level and passing the -Dlog4j.configuration=  
_file:////Users/sunil/temp/log4j.xml_

[2015-Mar-13 06:56:41:437] DEBUG [Robert Bruce Banner]  
node\_sampler\_interval[5s]  
[2015-Mar-13 06:56:41:437] DEBUG [Robert Bruce Banner]  
node\_sampler\_interval[5s]  
[2015-Mar-13 06:56:41:500] DEBUG [Robert Bruce Banner] adding address  
[[#transport#-1][sunil.local][inet[localhost/127.0.0.1:9300]]]  
[2015-Mar-13 06:56:41:500] DEBUG [Robert Bruce Banner] adding address  
[[#transport#-1][sunil.local][inet[localhost/127.0.0.1:9300]]]

but no luck so far

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/4cdfbc5d-6e79-4639-adef-5d7534f5e08c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/4cdfbc5d-6e79-4639-adef-5d7534f5e08c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Sunil](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@Sunil](https://discuss.elastic.co/u/Sunil)\
**Post date:** [March 13, 2015, 6:25pm UTC](https://discuss.elastic.co/t/how-do-i-enable-logging-for-elasticsearch-java-client/22655/2 "2015-03-13T18:25:08Z")

</div>

So i found out one way of enabling logs by hardcoding following in my  
application

import org.elasticsearch.common.logging.ESLoggerFactory;

ESLoggerFactory.getRootLogger().setLevel("TRACE");

Now i am able to see some log being generated.

Sunil

On Friday, March 13, 2015 at 7:27:49 AM UTC-7, Sunil Patil wrote:

> I built this standalone Java application that is connecting to  
> elasticSearch using Transport client on my local machine. I am trying to  
> figure out how to enable logging in it (This is to help me debug a wiered  
> streamcorrupexception that i am getting in my production cluster) but not  
> able to get it working. Can some one help
> 
> This is how my log4j.xml looks like [log4j.xml](https://gist.github.com/1023a89b8f40f6e43fe9.git) and this  
> is how my pom.xml file for application looks like [pom.xml](https://gist.github.com/ac1a373e8c043181f474.git). My java  
> client does create simple TransportClient and executes match all query on  
> it, the query is working ok. But i dont see much logs being created. I also  
> tried setting --Des.logger.level and passing the -Dlog4j.configuration=  
> _file:////Users/sunil/temp/log4j.xml_
> 
> [2015-Mar-13 06:56:41:437] DEBUG [Robert Bruce Banner]  
> node\_sampler\_interval[5s]  
> [2015-Mar-13 06:56:41:437] DEBUG [Robert Bruce Banner]  
> node\_sampler\_interval[5s]  
> [2015-Mar-13 06:56:41:500] DEBUG [Robert Bruce Banner] adding address  
> [[#transport#-1][sunil.local][inet[localhost/127.0.0.1:9300]]]  
> [2015-Mar-13 06:56:41:500] DEBUG [Robert Bruce Banner] adding address  
> [[#transport#-1][sunil.local][inet[localhost/127.0.0.1:9300]]]
> 
> but no luck so far

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/6b2a9449-9d72-405d-bf6b-6429d3f33043%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6b2a9449-9d72-405d-bf6b-6429d3f33043%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:26am UTC](https://discuss.elastic.co/t/how-do-i-enable-logging-for-elasticsearch-java-client/22655/3 "2017-07-06T00:26:54Z")

</div>


