ValueError: I/O operation on closed file

dj d.a.abernathy at
Fri Apr 10 22:25:25 CEST 2009

I have a handler which I use with a set of log levels for the python
logging module.

import logging.handlers

# create my handler class
class MyHandler(logging.handlers.RotatingFileHandler):
    def __init__(self, fn):
        logging.handlers.RotatingFileHandler.__init__(self, fn,
maxBytes=10485760, backupCount=5)

# Register handler in the "logging.handlers" namespace
logging.handlers.MyHandler = MyHandler

Using it, repeatedly generates this error:

Traceback (most recent call last):
  File "C:\python26\lib\logging\", line 74, in emit
    if self.shouldRollover(record):
  File "C:\python26\lib\logging\", line 146, in
shouldRollover, 2)  #due to non-posix-compliant Windows
ValueError: I/O operation on closed file

I am completely stumped  has to what could be the issue.
Any help would be greatly appreciated.

More information about the Python-list mailing list