logging module built using the python

Reference material

https://www.python.org/dev/peps/pep-0282/
https://docs.python.org/zh-cn/3/library/logging.html

Emphasis

effect

Recording system running log. The role of the log on the lot to Web logs, for example, consists of the following functions:

  • Through the website logs the user can clearly know what IP, what time, what operating system which pages you visited the site
  • Web logs can know through the site in addition to some sort of problem, easy maintenance
  • You know basic website crawler spider crawling situation
  • You can know which pages users are most likely to visit
    ......

Some people may ask, where to save the log it? Of course, the log is required to save the text file.

The log file is too large how to do?

  • A day can save the log text file
  • You can delete expired logs on a regular basis, such as: save only three months of logs

Log Level

CRITICAL
ERROR
WARNING
INFO
DEBUG
NOTSET

Basic use

import logging

logging.debug('debug message')
logging.info('info message')
logging.warn('warn message')
logging.error('error message')
logging.critical('critical message') 

Four components

Loggers is (logger)
the Handlers (Log Processor)
the Filters (log filter)
Formatters (formatted)

For more details, please refer to the official documentation.

Guess you like

Origin www.cnblogs.com/tantanjishu/p/11671429.html