The built-in

Python module logging management at different levels of log printing and storage, very convenient, bid farewell to the print driving record, we look at the logging

 import logging logging.basicConfig Charm (level = logging.DEBUG, format = '(asctime) s% (filename) s[line:% (lineno) d]% (levelname) s% (message) S', datefmt ='%a,%d%b%Y%H:%M:%S', filename ='./logcheck.log', FileMode ='w') ############################################################################### #define one StreamHandler, set the log mode console = logging.StreamHandler (console.setLevel) (logging.INFO) (formatter = logging.Formatter' (name) -12s:% (levelname) -8s% (message) S') console.setFormatter (formatter) logging.get Logger ('').AddHandler (console) = r'C:ddms.bat'('Open ############################################################################### filePath logging.error file failed!') logging.warn ('sort mode disabled') logging.debug ('%s'% filePath) logging.info ('xml file generated successfully 

! '):

 root results: ERROR Open file failed WARNING sort mode disabled! Root: root: INFO XML file generated successfully! 

the above is the summary of all the content on the Python logging management at different levels of log printing and storage of examples, we hope to help. Interested friends can continue to refer to other relevant topics of the station, if there are shortcomings, welcome the message. Thank you for the support of our friends!

This paper fixed link:http://www.script-home.com/python-logging-manages-different-levels-of-log-printing-and-storage-instances.html | Script Home | +Copy Link

Article reprint please specify:Python logging manages different levels of log printing and storage instances | Script Home

You may also be interested in these articles!