简体   繁体   English

Python RotatingFileHandler错误

[英]Error in Python RotatingFileHandler

I'm using logging.handlers.RotatingFileHandler class for logging. 我正在使用logging.handlers.RotatingFileHandler类进行日志记录。

This is how I'm using it. 这就是我的使用方式。

logging.handlers.RotatingFileHandler(logpath, "a", maxBytes=2500000, backupCount=5)

The log files are named in this format python.log.x where x=1,2..5 日志文件以python.log.x格式命名,其中x = 1,2..5

The log files are generated. 日志文件已生成。

The problem I see here is 我在这里看到的问题是

In python.log.5 log file, I'm seeing this entry 在python.log.5日志文件中,我看到了此条目

2013-06-05 09:58:29,994 2013-06-05 09:58:29,994

In python.log.4 log file, I'm seeing this entry 在python.log.4日志文件中,我看到了此条目

2013-06-05 09:56:29,994 2013-06-05 09:56:29,994

But this is wrong. 但这是错误的。 The entries are seen reversed where the 2013-06-05 09:58:29,994 should be in python.log.4 log file and 2013-06-05 09:56:29,994 should be in python.log.5 log file. 可以看到条目颠倒了,其中2013-06-05 09:58:29,994应该在python.log.4日志文件中,而2013-06-05 09:56:29,994应该在python.log.5日志文件中。

这必须发生,因为您的日志记录类正在被多个进程使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM