logging模块学习

参考链接:
https://docs.python.org/zh-cn/3/library/logging.html?highlight=logging#levels
logrecord参考

常用配置

import logging

logging.basicConfig(format='%(asctime)s -%(lineno)d %(message)s',)
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
import logging


FORMAT = '%(asctime)s %(levelname)s %(name)s %(module)s %(lineno)s  %(message)s'
logging.basicConfig(format=FORMAT)
logger = logging.getLogger("test")
logger.warning(__name__)

#output
#2022-04-13 21:28:38,322 WARNING test logging_test 8  __main__
posted @ 2022-04-07 23:01  绣幕  阅读(19)  评论(0编辑  收藏  举报