I'm using org.elasticsearch.client.RestHighLevelClient to run queries.
According to the official documentation, it's possible to log requests in curl format:
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-low-usage-logging.html
I have added the following line to my log4j.properties:
log4j.logger.org.elasticsearch.client = debug
Now I see http requests, but, how can I set curl formatting?
According to their documentation, you need to enable specific tracer logger, that is responsible specifically for curl format response.
You could achieve this in log4j 1.x with following lines:
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{yyyy-MM-dd HH:mm:ss}] [%-5p] %c{1}:%L - %m%n
log4j.logger.tracer=TRACE, stdout
Just in case someone doesn't want to bother oneself with loggers, it's possible to call toString() on QueryBuilder and see a request.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With