Menu
- logging定义
- logging - basicConfig
logging定义
logging - basicConfig
import logging
# ------ Config logging ------
logging.basicConfig(level=logging.DEBUG, # 从什么级别开始打印
format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s', # set打印格式
datefmt='%a, %d %b %Y %H:%M:%S', # set时间格式
filename='test.log', # 打印到哪里 - 填文件path
filemode='w') # 填文件打开mode
# ------ print loginfo ------
logging.debug('debug message') # 各级别的信息
logging.info('info message')
logging.warning('warning message')
logging.error('error message')
logging.critical('critical message')