You have three levels of logging: debug > info > warning. The strongest level is debug, and the weakest is warning.
import logging
logging.warning('Watch out!') # will print a message to the console
logging.info('I told you so') # will not print anything
You can use "basicConfig()" method to login the info to the file. For level, if you choose "DEBUG", every debug/info/warning message is logged, with "INFO", only info/waring, and so on.
import logging
logging.basicConfig(filename='example.log',level=logging.DEBUG)
logging.debug('This message should go to the log file')
logging.info('So should this')
logging.warning('And this, too')
No comments:
Post a Comment