scrapy set logger logs

1, set the log level in settings, add a line in settings.py in:

LOG_LEVEL = 'WARNING'

Scrapy offer 5 layer logging level:

CRITICAL - Critical error

ERROR - General error

WARNING - warning messages

INFO - General Information

DEBUG - Debug Information

scrapy default log information display DEBUG level

2, the result is saved log log output, and adds the path in settings.py:

LOG_FILE = './log.log'

It may be used by the logging in setting.py the following settings:

LOG_ENABLED default: True, Enable logging

LOG_ENCODING Default: 'utf-8', encoded using logging

LOG_FILE Default: None, create logging output file in the current directory in the file name

LOG_LEVEL default: 'DEBUG', log lowest level

3, the display position of the log, in the pipelines.py:

import logging

logger = logging.getLogger(__name__)

def process_item(self, item, spider):
    logger.warning(item)
    ....

Guess you like

Origin www.cnblogs.com/vinic-xxm/p/11764433.html