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: Problems with delay parm of logging.handlers.RotatingFileHandler
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: pycurry, vinay.sajip
Priority: normal Keywords:

Created on 2009-01-20 16:21 by pycurry, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg80258 - (view) Author: Fons Dijkstra (pycurry) Date: 2009-01-20 16:21
When you set the delay parameter of the 
logging.handlers.RotatingFileHandler.__init__() function to True, two 
things go wrong:

1) A previously set formatter is reset (to None) upon lazy creating the 
StreamHandler. That means in practice that you always will have the 
default formatter which just formats the message.

2) Upon a roll-over, the delay parm does not seem to be used anymore as, 
even if there are no records to log, the new current logfile is always 
created.
msg80293 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2009-01-20 23:28
Fixes now in trunk and release26-maint.

Note that RotatingFileHandler will open the file when shouldRollover()
is called - which it is from emit() - and doRollover() will also open
the file even if a delay parameter is set.

TimedRotatingFileHandler will not open a file if delay is set until
rollover actually occurs, as shouldRollover goes by time only rather
than file size.

The delay parameter is intended only as a hint to the handlers to delay
opening until as long as possible, and they will try to honour this as
far as is practicable.
History
Date User Action Args
2022-04-11 14:56:44adminsetgithub: 49263
2009-01-20 23:28:45vinay.sajipsetstatus: open -> closed
resolution: fixed
messages: + msg80293
2009-01-20 16:22:48benjamin.petersonsetassignee: vinay.sajip
nosy: + vinay.sajip
2009-01-20 16:21:21pycurrycreate