版权声明:本文为徐代龙原创文章,未经徐代龙允许不得转载。网络资源网站:xudailong.cc 福利网站:www.00reso.com 公众号:蛇崽网盘教程资源 https://blog.csdn.net/xudailong_blog/article/details/83545991
在使用scrapy
框架的时候,因为scrapy
在屏幕上面输出的日志一直在跑,有些错误又抓不到,无奈只能先把log日志
放在文件中,慢慢进行错误日志的分析。
如图所示:
我们需要设置的地方只在settings.py
文件夹中进行设置就可以了。
LOG_LEVEL = 'DEBUG'
to_day = datetime.datetime.now()
log_file_path = 'log/scrapy_{}_{}_{}.log'.format(to_day.year, to_day.month, to_day.day)
LOG_FILE = log_file_path
这里我设置scrapy log
日志为DEBUG
级别,也就是屏幕上输出的级别,最低的级别,如果你想让你自己所打印的log
出现在log
文件中,你可以在spider
里面这样用
这样我们就会在txt
文本中看到这个日志了。
--------------------------------------- 下面是个人信息 ------------------------------------------------
个人微信:hll643435675(备注:博客)
更多资源请访问:
https://blog.csdn.net/xudailong_blog/article/details/78762262
慕课视频教程:https://blog.csdn.net/xudailong_blog/article/details/82909611
https://xudailong.cc/2018/09/30/muke-courses/
更多资源请关注公众号(蛇崽网盘教程资源 ):
--------------------------------------- 上面是个人信息 ------------------------------------------------