def getLog(name):
logger=logging.getLogger(name)
#日志级别DEBUG、INFO、WARNING、ERROR、CRITICAL
logger.setLevel(logging.DEBUG)
rfh=RotatingFileHandler("log/log.txt",maxBytes=5000000,backupCount=5)
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
rfh.setFormatter(formatter)
logger.addHandler(rfh)
return logger
发现问题:
我是使用web.py做的web应用,当代码出现未捕获的异常后,日志会重复记录