我如何为elasticsearch库设置与自己的日志不同的日志级别?为了说明这个问题,我描述一下模块的情况。我有一个模块
lookup.py
,它像这样使用
elasticsearch
。
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'])
然后在我的主文件中,我做
import logging
import lookup.py
logging.root.setLevel(loglevel(args))
get_docs()
我得到了很多来自以下方面的调试信息insideElasticsearch对象。我怎样才能用lookup.py
中的一些代码抑制它们,而不抑制lookup.py
本身的调试信息?Elasticsearch
类似乎有一个logger
对象;我我试着把它设置为None
,但这并没有改变什么。