[英]Fixed size log file containing only the most recent entries
I have a bug that is guaranteed to happen if the program runs long enough (more than an hour.) 如果程序运行足够长的时间(超过一个小时),我肯定会发生一个错误。
The only way to solve this is to print a massive amount of debugging information, which unfortunately is growing at a rate of 1MB/s! 解决此问题的唯一方法是打印大量调试信息,不幸的是,调试信息正以1MB / s的速度增长!
Though util.Logging.FileHandler has the option to set the size limit of the log files, it simply erases the files and write from scratch once the limit is reached. 尽管util.Logging.FileHandler可以选择设置日志文件的大小限制,但只要达到限制,它就会简单地擦除文件并从头开始写入。
Is there a way to write to a log file in a "rolling" manner, such that on exceeding size limit, newest entries displace oldest ones instead of wiping everything out? 有没有一种方法可以以“滚动”方式写入日志文件,从而在超出大小限制时,最新条目将替换最旧条目而不是清除所有内容? Currently, I juggle among the log files, but it can get confusing. 目前,我在日志文件中混用,但可能会造成混乱。
Thank you! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.