RotatingFileHandler throws an exception when delay parameter is set
handlers, logging, python
Solution
I've investigated this issue: it was fixed in Python SVN r68829 dated 20 Jan, 2009. This was after the release of 2.6.1 but before the release of 2.6.2.
Please upgrade to Python 2.6.2, or a later version.
I've updated the bug you filed. BTW the original bug report filed was #5013, which you could have found by searching all issues (not just open ones) for `RotatingFileHandler`, like this (from this page).
Problem
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.