Use of logs in scrapy

1. settings

# ----------------LOG设置------------------
# LOG_ENABLED = False  # 默认: True,启用logging
LOG_LEVEL = 'DEBUG'  # 输出DEBUG及以上级别的日志
to_day = datetime.datetime.now()
log_file_path = 'log/scrapy_{}_{}_{}_{}_{}.log'.format(to_day.year, to_day.month, to_day.day, to_day.hour,
                                                       to_day.minute)
LOG_FILE = log_file_path  # 保存路径

 

2. Direct import logging in spiders and then call directly

(Not valid in the class and valid only in the method)

import logging
logging.info('这是INFO')

 3. The console no longer outputs logs, all are saved in the log file

 

Guess you like

Origin blog.csdn.net/xkx_07_10/article/details/94554750