homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: TimedRotatingFileHandler logic for removing files wrong
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: ceder, vinay.sajip
Priority: normal Keywords:

Created on 2008年03月17日 08:29 by ceder, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (2)
msg63626 - (view) Author: Per Cederqvist (ceder) Date: 2008年03月17日 08:29
There are three issues with log file removal in the
TimedRotatingFileHandler class:
 - Removal will stop working in the year 2100, as the code assumes that
 timestamps start with ".20".
 - If you run an application with backupCount set to a high number, and
 then restarts it with a lower number, the code will still not remove
 as many log files as you expect. It will never remove more than one
 file when it rotates the log.
 - It assumes that no other files matches baseFilename + ".20*", so
 make sure that you don't log to both "log" and
 "log.20th.century.fox" in the same directory!
Suggested fix: use os.listdir() instead of glob.glob(), filter all
file names using a proper regexp, sort the result, and use a while
loop to remove files until the result is small enough. To reduce the
risk of accidentally removing an unrelated file, the filter regexp
should be based on the logging interval, just as the filename is.
My suggested fix means that old files may not be removed if you change
the interval. I think that is an acceptable behavior, but it should
probably be documented to avoid future bug reports on this subject. :-)
msg64879 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2008年04月02日 21:11
Updated SVN, but not backported to 2.5 or earlier maintenance branches.
History
Date User Action Args
2022年04月11日 14:56:31adminsetgithub: 46570
2008年04月02日 21:11:57vinay.sajipsetstatus: open -> closed
resolution: fixed
messages: + msg64879
2008年03月17日 19:26:43georg.brandlsetassignee: vinay.sajip
nosy: + vinay.sajip
2008年03月17日 08:29:36cedercreate

AltStyle によって変換されたページ (->オリジナル) /