Pythong logging 模块简单使用方法
示例如下:
----------------------------------------------------------------
import logging
logging.basicConfig(
filename="config.log",
format='%(asctime)s [%(levelname)-7s] %(message)s',
level=logging.DEBUG,
filemode='w')
logging.debug('A debug message')
logging.info('Some information')
logging.warning('A shot across the bows')
输出结构如下:
----------------------------------------------------------------
2010-11-22 23:18:08,046 [DEBUG ] A debug message
2010-11-22 23:18:08,046 [INFO ] Some information
2010-11-22 23:18:08,046 [WARNING] A shot across the bows
Python logging
最新推荐文章于 2024-03-08 15:10:03 发布