我的蜘蛛产生了大量的日志消息,如下所示:
2017-09-21 21:54:30 [botocore.vendored.requests.packages.urllib3.connectionpool] INFO: Starting new HTTPS connection (250): s3.eu-central-1.amazonaws.com
在settings.py
中,我的日志记录级别设置为
LOG_LEVEL = 'INFO'
我已在此设置urllib3
的日志记录级别:
class ExampleSpider(scrapy.Spider):
name = "example"
def __init__(self):
self.domain = 'http://www.example.com'
self.user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0) Gecko/20100101 Firefox/10.0"
logging.basicConfig(level=logging.INFO)
logging.getLogger('requests').setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
为什么我仍然收到消息?
答案 0 :(得分:0)
使用
打印活动记录器import logging
for key in logging.Logger.manager.loggerDict:
print(key)
然后执行类似
的操作logging.getLogger('botocore.vendored.requests.packages.urllib3.connectionpool').setLevel(logging.NOTSET)