More extensive Elasticsearch request/response logging

Description

It would be interesting and would help a lot in development, if we could see the output Json sent to elasticsearch, similar to what we have in hibernate for SQL.

<property name="hibernate.show_sql" value="true"/> <property name="hibernate.format_sql" value="true"/>

Maybe some property to enable it like this:

<property name="hibernate.search.default.elasticsearch.show_json" value="true"/> <property name="hibernate.search.default.elasticsearch.pretty_json" value="true"/>

Thank you.

Activity

Leandro Kersting de FreitasAugust 28, 2017 at 1:16 PM

Hello ,

I think it's a good idea.

My suggestion would be more for loggers in the requests, of course the response is important.
We could also have a configuration option for response.

It would help a lot in development, and of course the developer needs to be aware that the logs might be giants, but it could benefit us in tracking down possible errors and behaviors.

I could do a PR, but I'm not updated to the code of this project. Maybe you can designate another person.

Yoann RodièreAugust 28, 2017 at 8:43 AM

Hello ,

We already provide this feature through the org.hibernate.search.fulltext_query logger. Set its level to DEBUG or more verbose, and all search queries will be logged.
If you want to log every request sent to the Elasticsearch cluster (including PUT/DELETE etc.), you can use the org.hibernate.search.elasticsearch.request logger (set its level to TRACE or more verbose).
See here: https://docs.jboss.org/hibernate/search/5.8/reference/en-US/html_single/#elasticsearch-logging

The org.hibernate.search.elasticsearch.request logger does not print the JSON content of requests though, mainly because it would be very, very verbose (you can have hundreds of documents in one request). I suppose we could add options to control that, or maybe show only path + query parameters at the DEBUG level, and the whole request at the TRACE level.

And of course, there's the problem of formatting. We could add a configuration option for that, controlling formatting for both the org.hibernate.search.fulltext_query and org.hibernate.search.elasticsearch.request loggers.

Any remarks about the above, before we start working on it?

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created August 26, 2017 at 11:06 AM
Updated September 13, 2017 at 10:15 PM
Resolved September 1, 2017 at 3:35 PM