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 timerotatingfilehandler中将滚动时间作为积分点_Python_Logging - Fatal编程技术网

如何在python timerotatingfilehandler中将滚动时间作为积分点

如何在python timerotatingfilehandler中将滚动时间作为积分点,python,logging,Python,Logging,python timerotatingfilehandler的初始滚动时间是最新的文件修改时间。它并不总是在一个积分点上。例如,当我设置参数when='H'时,如何在积分点设置滚动时间,例如14:00:00而不是14:15:30?这可以通过手动设置初始滚动时间属性来完成。因此,当时间为14:15时,您告诉处理程序在15:00进行翻滚,从那里开始,每次翻滚都会增加一个小时 从日志导入TimedRotatingFileHandler 从日期时间导入日期时间 handler=TimedRotating

python timerotatingfilehandler的初始滚动时间是最新的文件修改时间。它并不总是在一个积分点上。例如,当我设置参数
when='H'
时,如何在积分点设置滚动时间,例如14:00:00而不是14:15:30?

这可以通过手动设置初始滚动时间属性来完成。因此,当时间为14:15时,您告诉处理程序在15:00进行翻滚,从那里开始,每次翻滚都会增加一个小时

从日志导入TimedRotatingFileHandler
从日期时间导入日期时间
handler=TimedRotatingFileHandler('file.log',when='H')
last_full_hour=datetime.now().replace(分钟=0,秒=0).timestamp()
handler.rolloverAt=last_full_hour+handler.interval#3600也可以