简体   繁体   English

以脚本运行Scrapy时禁用日志

[英]Disabling logs when running Scrapy as script

I'm using Scrapy in a script of mine as describe in the Common Practices on the docs 我在我的脚本中使用Scrapy,如文档的“ 常规做法”中所述

I need to disable the Scrapy logs completely (not change verbosity). 我需要完全禁用Scrapy日志(不要更改详细程度)。 I tried this: 我尝试了这个:

Spider.custom_settings['LOG_ENABLED'] = False

and this: 和这个:

configure_logging({'LOG_ENABLED': False})

In both cases, Scrapy is still logging everything. 在这两种情况下,Scrapy仍然记录所有内容。

How do you completely disable Scapy logs when running Scrapy in a script (note that I have my own logger that I want to keep, it's just Scrapy logs that I want to remove). 在脚本中运行Scrapy时,如何完全禁用Scapy日志(请注意,我有自己的记录器要保留,只是要删除的Scrapy日志)。

我能够使用以下方法解决此问题:

logging.getLogger('scrapy').propagate = False

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM