import logging
?
# 设置logging 格式
logging.basicConfig(level=logging.DEBUG, # 打印日志等级
format=‘%(filename)s %(levelname)s ‘
‘[%(lineno)d] - %(threadName)s : %(message)s‘
‘ - %(asctime)s‘, # 日志内容
datefmt=‘[%d/%b/%Y %H:%M:%S]‘, # 日期格式
# filename=‘./my.log‘, # 日志存放位置
# filemode=‘w‘
)
?
?
# 实例化一个logger
logger = logging.getLogger(__name__)
from basiclog.BasicLog import logger
?
?
if __name__ == ‘__main__‘:
logger.info("this is a log test info")
logger.debug("this is a log test debug")
logger.warning("this is a log test warning")
?
原文:https://www.cnblogs.com/jacky-pivot/p/14673767.html