小编Ran*_*ndi的帖子

日志记录 - 如何忽略导入的模块日志?

如何忽略来自导入模块的日志条目(不是我写的)?

设置:

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)

python debugging logging python-2.7

7
推荐指数
2
解决办法
4629
查看次数

标签 统计

debugging ×1

logging ×1

python ×1

python-2.7 ×1