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