Python 记录TimedRotatingFileHandler don';我不能正常工作
日志记录包中的TimedRotatingFileHandler无法正常工作。我的节目来源:Python 记录TimedRotatingFileHandler don';我不能正常工作,python,logging,Python,Logging,日志记录包中的TimedRotatingFileHandler无法正常工作。我的节目来源: from logging.handlers import TimedRotatingFileHandler import logging logger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) handler = TimedRotatingFileHandler("log/log_file.log", when="d") h
from logging.handlers import TimedRotatingFileHandler
import logging
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
handler = TimedRotatingFileHandler("log/log_file.log", when="d")
handler.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
几天后,出现了两个问题。
首先,它再次写入log\u文件.log。
其次,日志记录A日B日的事件。例如:
File name:
log_file.log.2018-06-21
及
在本例中,6月23日的事件错误地写入了6月21日的文件。此处理程序始终写入基本文件(xxx.log)。到了滚动的时候,文件将关闭、重命名,并再次打开具有基本文件名的文件 如果使用多个进程写入同一文件(可能使用UWSGI),则可能会偶尔出现问题-支持从多个进程写入同一文件,但不支持您这样做。有关更多信息,请参阅和
File content:
2018-06-23 08:05:42,906 - uwsgi_file__home_ddddd_main - INFO -
2018-06-23 08:05:42,907 - uwsgi_file__home_ddddd_main - DEBUG -