I am using python-elasticsearch module, I read in the python-elasticsearch documentation that you can log all the underlying HTTP requests as command line curl commands:
elasticsearch.trace can be used to log requests to the server in the form of curl commands using pretty-printed json that can then be executed from command line. Because it is designed to be shared (for example to demonstrate an issue) it also just uses localhost:9200 as the address instead of the actual address of the host. If the trace logger has not been configured already it is set to propagate=False so it needs to be activated separately.
For python-elasticsearch module, how do you enable this curl logging?
I tried:
- setting the global logger to
logging.basicConfig(level=logging.DEBUG)but that didn't output the curl - I tried getting the
elasticsearch.tracelogger and setting that logger's level tologging.DEBUGand then settinges_trace_logger.propagate = Truebut neither of those worked
elasticsearchlogger and set its level to DEBUGlogger = logging.getLogger('elasticsearch'); logger.setLevel(logging.DEBUG)? have you tried this and know it works?elasticsearchlogger will only show you theGET/POSTrequest and the corresponding response. Theelasticsearch.tracelogger will show the same info in a better manner as a curl request and in prettified json.