一、简单使用
复制代码 代码如下:
def TestLogBasic():
import logging
logging.basicConfig(filename = 'log.txt', filemode = 'a', level = logging.NOTSET, format = '%(asctime)s - %(levelname)s: %(message)s')
logging.debug('this is a message')
logging.info("this is a info")
logging.disable(30)#logging.WARNING
logging.warning("this is a warnning")
logging.critical("this is a critical issue")
logging.error("this is a error")
logging.addLevelName(88,"MyCustomError")
logging.log(88,"this is an my custom error")
try:
raise Exception('this is a exception')
except:
logging.exception( 'exception')
logging.shutdown()
TestLogBasic()
Copyright© 2013-2020
All Rights Reserved 京ICP备2023019179号-8