Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 记录TimedRotatingFileHandler don';我不能正常工作_Python_Logging - Fatal编程技术网

Python 记录TimedRotatingFileHandler don';我不能正常工作

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

日志记录包中的TimedRotatingFileHandler无法正常工作。我的节目来源:

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。 其次,日志记录AB日的事件。例如:

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 -