ValueError: I/O operation on closed file

dj d.a.abernathy at gmail.com
Fri Apr 10 16:25:25 EDT 2009


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

----------------------------------- myhandler.py
--------------------------------------------------------
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\handlers.py", line 74, in emit
    if self.shouldRollover(record):
  File "C:\python26\lib\logging\handlers.py", line 146, in
shouldRollover
    self.stream.seek(0, 2)  #due to non-posix-compliant Windows
feature
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