import logging
logging.basicConfig(
level=logging.DEBUG,
format='[%(asctime)s <%(filename)s :%(lineno)d>] [%(levelname)s] %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
# 日志输出到文件,文件名字可以自定义
# filename='app.log',
# 日志记录形式,追加模式
# filemode='a'
)
logging.debug('This is debug message')
logging.info('This is info message')
logging.warning('This is warning message')
转载于:https://www.cnblogs.com/by2016/p/6919089.html