The-logging of the Python module

Source: Internet
Author: User

Python module logging

Import logging

# # # Simple to use the format log level level critical > ERROR > WARNING > INFO > DEBUG > NOTSET

Logging.debug (' Debug Message ')      #  logging. Log level (' User output information ') Logging.info (' info message ')  logging.warning ( ' Warning message ')  logging.error (' error message ')  logging.critical (' critical message ')

# # # Configuration Log Output

Logging.basicconfig (level=logging. DEBUG,                      format= '% (asctime) s% (filename) s[line:% (lineno) d]% (levelname) s% (message) s ',                      datefmt= '%a,%d%b%Y%H :%m:%s ',  #输出时间格式                    filename= '/tmp/test.log ',                              filemode= ' W ')    
formatting strings that may be used in the format parameter:
% (name) s logger name
% (Levelno) s log level in digital form
% (levelname) s log level in text form
% (pathname) s calls the full pathname of the module of the log output function and may not have
% (filename) s The file name of the module that called the log output function
% (module) s call the module name of the log output function
% (FuncName) s Call the function name of the log output function
% (Lineno) d The line of code where the statement of the log output function is called
% (created) F current time, represented by the UNIX standard floating-point number representing the time
% (relativecreated) d when the log information is output, the number of milliseconds since logger was created
% (asctime) s The current time in string form. The default format is "2003-07-08 16:49:45,896". The comma is followed by milliseconds
% (thread) d thread ID. Probably not.
% (threadname) s thread name. Probably not.
% (process) d process ID. Probably not.
% (message) s user-output message




The-logging of the Python module

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.