我正在尝试从我的脚本启动 scrapy 爬虫,如此处所示:here
logging.basicConfig(
filename='log.txt',
format='%(levelname)s: %(message)s',
level=logging.CRITICAL
)
configure_logging(install_root_handler=False)
process = CrawlerProcess(get_project_settings())
process.crawl('1740')
process.start() # the script will block here until the crawling is finished
我想配置我的爬虫的日志级别,但即使我不安装根记录器处理程序并使用logging.basicConfig方法配置基本配置,它也不遵守确定的级别。
INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
'scrapy.spidermiddlewares.referer.RefererMiddleware',
'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
'scrapy.spidermiddlewares.depth.DepthMiddleware']
INFO: Enabled item pipelines:
['collector.pipelines.CollectorPipeline']
INFO: Spider opened
INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
它遵循basicConfig中确定的格式和文件名,但不使用日志级别。除了这个地方,我不确定日志级别。
注意:我没有导入或更改日志级别的其他地方。
LOG_LEVEL = 'DEBUG'
,其他设置是否强制执行?我已将我的设置为DEBUG
,但我没有得到任何额外的信息! - J86