Use scrapy for Logging, scrapylogging

Source: Internet
Author: User

Use scrapy for Logging, scrapylogging

 

# Coding: UTF-8 _ author _ = 'similarface' ######################### use of Logging ### ################## import logging ''' 1. logging. CRITICAL-for critical errors (highest severity) fatal error 2. logging. ERROR-for regular errors ERROR 3. logging. WARNING-for warning messages WARNING + error 4. logging. INFO-for informational messages Message + warning + error 5. logging. DEBUG-for debugging messages (lowest severity) low level '''logging. warning ("This is a warning") logging. log (logging. WARNING, "This is a warning") # obtain the Instance Object logger = logging. getLogger () logger. warning ("this is a warning message") # specify the message sender logger = logging. getLogger ('similarface') logger. warning ("This is a warning") # Use logimport scrapyclass MySpider (scrapy. spider): name = 'myspider 'start_urls = ['HTTP: // scrapinghub.com'] def parse (self, response ): # logger self.logger.info ('parse function called on % s', response. url) # method 2 define a logger logger.info ('parse function called on % s', response. url) '''logging settings • LOG_FILE • LOG_ENABLED • Logging • LOG_LEVEL • LOG_FORMAT • LOG_DATEFORMAT • Use -- logfile FILEOverrides LOG_FILE -- loglevel/-L limit LOG_LEVEL -- nosets LOG_ENABLED to false' ''import loggingfrom scrapy. utils. log import configure_loggingconfigure_logging (install_root_handler = False) # defines some logging attributes. basicConfig (filename = '/Users/similarface/PycharmProjects/FluentPython/log.txt', format = '% (levelname) s: % (message) s ', level = logging. INFO) # append mode logging.info ('Log file') logger = logging. getLogger ('similarface') logger. warning ("Log files also required ")

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.