首页 > 代码库 > 在python中使用logging模块

在python中使用logging模块

import logging
logging.basicConfig(level=logging.INFO, filename=‘mylog.log‘)
logging.info(‘Starting program‘)
logging.info(‘Trying to divide 1 by 0‘)
print 1 / 0
logging.info(‘The division succeeded‘)
logging.info(‘Ending program‘)