如何忽略来自导入模块的日志条目(不是我写的)?
设置:
import logging
import <someOtherModule>
logging.basicConfig(level=logging.INFO)
class myClass:
...
def some_method(self):
logging.info('calling module')
someOtherModule.function()
logging.info('stuff happened')
if __name__ == "__main__":
a = myClass().some_method()
Run Code Online (Sandbox Code Playgroud)
日志:
INFO:root:calling module
INFO:<someOtherModule>.<some dependency> <random dependency message here>
INFO:root:stuff happened
Run Code Online (Sandbox Code Playgroud)
我怎样才能摆脱那个中间消息?
查看日志记录文档或通过谷歌搜索后,我无法找到答案。
我找到了这个答案,但解决方法似乎对我不起作用。
对于好奇的人,实际的日志条目是:
INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): <address here>
Run Code Online (Sandbox Code Playgroud)