How to set the logging level for the elasticsearch library differently to my own logging? : <p>How can I set the logging level for the elasticsearch library differently to my own logging? To illustrate the issue, I describe the module scenario. I have a module <code>lookup.py</code> which uses <code>elasticsearch</code> like this:</p>

<pre><code>import logging
logger = logging.getLogger(__name__)
import elasticsearch

def get_docs():
    logger.debug("search elastic")
    es = elasticsearch.Elasticsearch('http://my-es-server:9200/')
    res = es.search(index='myindex', body='myquery')
    logger.debug("elastic returns %s hits" % res['hits']['total'])
    .
    .
.
</code></pre>

<p>Then in my main file I do</p>

<pre><code>import logging
import lookup.py

logging.root.setLevel(loglevel(args))
get_docs()
.
.
.
</code></pre>

<p>I get lots of debug messages from <em>inside</em> the Elasticsearch object. How can I suppress them with some code in <code>lookup.py</code> without suppressing the debug messages in <code>lookup.py</code> itself? The <code>Elasticsearch</code> class seems to have a <code>logger</code> object; I  I tried to set it to <code>None</code>, but this didn't change anything.</p>


