RotatingFileHandler throws an exception when delay parameter is set

Posted by Eli Courtwright on Stack Overflow See other posts from Stack Overflow or by Eli Courtwright
Published on 2010-03-17T19:02:06Z Indexed on 2010/03/17 20:11 UTC
Read the original article Hit count: 601

Filed under:
|
|

When I run the following code under Python 2.6

import logging
from logging.handlers import RotatingFileHandler

rfh = RotatingFileHandler("testing.log", delay=True)
logging.getLogger().addHandler(rfh)
logging.warning("Boo!")

then the last line throws AttributeError: RotatingFileHandler instance has no attribute 'level'. So I add the line

rfh.setLevel(logging.DEBUG)

before the call to addHandler, and then the last line throws AttributeError: RotatingFileHandler instance has no attribute 'filters'. So if I manually set filters to be an empty list, then it complains about not having the attribute lock, etc.

When I remove the delay=True to leave it as the default value of False as documented here, the problem completely goes away.

Am I missing something? How do I properly use the delay parameter of the RotatingFileHandler class?

EDIT: Upon further analysis (presented in my own answer below), this looks like a bug, but I can't find a bug report on this in the Python bug tracker, even trying different search terms, so I guess I'll report it.

However, if someone can locate the actual bug report, then I can avoid submitting a duplicate reporting and wasting the time of the Python developers. I'll hold off on reporting the bug for a few hours, and if someone posts an answer that has the current bug report, then I'll accept that answer for this question.

© Stack Overflow or respective owner

Related posts about python

Related posts about logging