Could not find handlers for "elasticsearch.trace" log

Updated: Turns out this is not a cron function. I get the same behavior when running a script from the command line if there really is an entry for processing and interacting with ElasticSearch.


I have a cron job that runs a python script that uses pyelasticsearch to index some documents in an ElasticSearch instance. The script works fine from the command line, but when run through cron, this leads to an error:

No handlers found for "elasticsearch.trace" log

Obviously, there is some log configuration problem that only appears when running in cron mode, but I don’t understand what it is. Any insight?

+7
python django pyelasticsearch
source share
1 answer

I solved this by explicitly configuring the handler for the elasticsearch.trace logger, as I saw in the examples from the repelasticsearch repo.

After importing pyelasticsearch, configure the handler as follows:

 tracer = logging.getLogger('elasticsearch.trace') tracer.setLevel(logging.INFO) tracer.addHandler(logging.FileHandler('/tmp/es_trace.log')) 

I am not interested in keeping trace logs, so I used the Django NullHandler located next to you.

 from django.utils.log import NullHandler tracer = logging.getLogger('elasticsearch.trace') tracer.setLevel(logging.INFO) tracer.addHandler(NullHandler()) 
+7
source share

All Articles