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: RotatingFileHandler cannot recover from failed doRollover()
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: forest, nnorwitz, vinay.sajip
Priority: normal Keywords:

Created on 2007-01-04 06:08 by forest, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg30912 - (view) Author: Forest (forest) Date: 2007-01-04 06:08
When RotatingFileHandler.doRollover() raises an exception, it puts the handler object in a permanently failing state, with no way to recover using RotatingFileHandler methods.  From that point on, the handler object raises an exception every time a message is logged, which renders logging in an application practically useless.  Furthermore, a handleError() method has no good way of correcting the problem, because the API does not expose any way to re-open the file after doRollover() has closed it.

Unfortunately, this is a common occurrence on Windows, because doRollover() will fail if someone is running tail -f on the log file.

Suggestions:

- Make doRollover() always leave the handler object in a usable state, even if the rollover fails.

- Add a reOpen() method to FileHandler, which an error handler could use to recover from problems like this.  (It would also be useful for applications that want to re-open log files in response to a SIGHUP.)

msg30913 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-01-04 06:27
Vinay, was this addressed?  I thought there was a similar issue.
msg30914 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2007-01-09 14:56
I've added an _open() method to logging.FileHandler [checked into trunk]. This facilitates reopening by derived class error handlers.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44406
2007-01-04 06:08:15forestcreate