标签:att warning war level mes imp str filters 目录文件
import logging
# 在logging.basciConfig中指定文件中写入
logging.basicConfig(
level=logging.DEBUG,
format=‘%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s‘,
datefmt=‘%a, %d %b %Y %H:%M:%S‘,
filename="E:\\test_allchips\\log\\logs\\test.log", # 注意xpath指定目录文件
filemode=‘a‘)
logging.debug("User %s is loging" % ‘jeck‘)
logging.info("User %s attempted wrong password" % ‘fuzj‘)
logging.warning("user %s attempted wrong password more than 3 times" % ‘mary‘)
logging.error("select db is timeout")
logging.critical("server is down")
# 打印到屏幕
logging.basicConfig(
level=logging.DEBUG,
format=‘%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s‘,
datefmt=‘%a, %d %b %Y %H:%M:%S‘)
logging.debug("User %s is loging" % ‘jeck‘)
logging.info("User %s attempted wrong password" % ‘fuzj‘)
logging.warning("user %s attempted wrong password more than 3 times" % ‘mary‘)
logging.error("select db is timeout")
logging.critical("server is down")
logging的四大组件
标签:att warning war level mes imp str filters 目录文件
原文地址:https://www.cnblogs.com/yancy03/p/10177868.html