# Log Search Queries

**URL:** <https://discuss.elastic.co/t/log-search-queries/3333>\
**Category:** Elasticsearch\
**Created:** [September 14, 2010, 3:54pm UTC](https://discuss.elastic.co/t/log-search-queries/3333 "2010-09-14T15:54:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kenneth\_Loafman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kenneth_loafman/32/2224_2.png) [@Kenneth\_Loafman](https://discuss.elastic.co/u/Kenneth_Loafman)\
**Post date:** [September 14, 2010, 3:54pm UTC](https://discuss.elastic.co/t/log-search-queries/3333/1 "2010-09-14T15:54:41Z")

</div>

Hi,

Is it possible to log search queries? I'm not familiar with Java logging.

...Thanks,  
...Ken

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [September 14, 2010, 4:18pm UTC](https://discuss.elastic.co/t/log-search-queries/3333/2 "2010-09-14T16:18:17Z")

</div>

On Tue, 2010-09-14 at 10:54 -0500, Kenneth Loafman wrote:

> Hi,
> 
> Is it possible to log search queries? I'm not familiar with Java logging.

It certainly is with the Perl client.

> **[ElasticSearch - An API for communicating with ElasticSearch - metacpan.org](https://metacpan.org/release/DRTECH/ElasticSearch-0.20/view/lib/ElasticSearch.pm)**
>
> An API for communicating with ElasticSearch

but that is implemented in the client, and not in Elasticsearch

clint

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [September 14, 2010, 7:02pm UTC](https://discuss.elastic.co/t/log-search-queries/3333/3 "2010-09-14T19:02:27Z")

</div>

As far as I know there is no combination of logging level and package name  
for the native ES Java client that would log user queries. This is  
intentional. There are two good reasons for this:

1. one single user query can yield several internal queries within ES
2. extensive logging can result into performance degradation  
A good way how to go about this is to log user queries on your side right  
before they are handed over to ES Java client.

Regards,  
Lukas

On Tue, Sep 14, 2010 at 6:18 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:

> On Tue, 2010-09-14 at 10:54 -0500, Kenneth Loafman wrote:
> 
> > Hi,
> > 
> > Is it possible to log search queries? I'm not familiar with Java  
> > logging.
> 
> It certainly is with the Perl client.
> 
> [ElasticSearch - An API for communicating with ElasticSearch - metacpan.org](http://search.cpan.org/~drtech/ElasticSearch-0.20/lib/ElasticSearch.pm#trace_calls())
> 
> but that is implemented in the client, and not in Elasticsearch
> 
> clint

---

<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:** [September 15, 2010, 10:38am UTC](https://discuss.elastic.co/t/log-search-queries/3333/4 "2010-09-15T10:38:08Z")

</div>

Yea, thats the idea. May I ask why you want to log queries?

On Tue, Sep 14, 2010 at 9:02 PM, Lukáš Vlček [lukas.vlcek@gmail.com](mailto:lukas.vlcek@gmail.com) wrote:

> As far as I know there is no combination of logging level and package name  
> for the native ES Java client that would log user queries. This is  
> intentional. There are two good reasons for this:
> 
> 1. one single user query can yield several internal queries within ES
> 2. extensive logging can result into performance degradation  
> A good way how to go about this is to log user queries on your side right  
> before they are handed over to ES Java client.
> 
> Regards,  
> Lukas
> 
> On Tue, Sep 14, 2010 at 6:18 PM, Clinton Gormley [clinton@iannounce.co.uk](mailto:clinton@iannounce.co.uk)wrote:
> 
> > On Tue, 2010-09-14 at 10:54 -0500, Kenneth Loafman wrote:
> > 
> > > Hi,
> > > 
> > > Is it possible to log search queries? I'm not familiar with Java  
> > > logging.
> > 
> > It certainly is with the Perl client.
> > 
> > [ElasticSearch - An API for communicating with ElasticSearch - metacpan.org](http://search.cpan.org/~drtech/ElasticSearch-0.20/lib/ElasticSearch.pm#trace_calls())
> > 
> > but that is implemented in the client, and not in Elasticsearch
> > 
> > clint

---

<div class="post-metadata">

**Author:** ![melix](https://avatars.discourse-cdn.com/v4/letter/m/b38774/32.png) [@melix](https://discuss.elastic.co/u/melix)\
**Post date:** [July 20, 2011, 9:20am UTC](https://discuss.elastic.co/t/log-search-queries/3333/5 "2011-07-20T09:20:17Z")

</div>

I have a similar need, for debugging purposes only : I use a query generator which builds rather complex queries and it would help debugging if I could see the "JSON form" of the generated query somewhere in the logs.

Right now I'm using a breakpoint in SearchRequestBuilder#doExecute. It works, but it is still difficult to use : copy the "toString" version of the builder, then paste and reformat in IDE.

---

<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:00am UTC](https://discuss.elastic.co/t/log-search-queries/3333/6 "2017-07-06T04:00:04Z")

</div>


