RotatingFileHandler Error

Roopesh roopesh.raj at gmail.com
Fri Dec 29 01:20:03 EST 2006


Hi
I am trying to use RotatingFileHandler, in the foll way :

rootLogger = logging.getLogger('')
rootLogger.setLevel(logging.DEBUG)
rotatingHandler =
logging.handlers.RotatingFileHandler(self.logobj_path.name,"a", 1000,
10)
rotatingHandler.doRollover()
rotatingHandler.emit()
rootLogger.addHandler(rotatingHandler)
logging.info('info')
self.logger = logging.getLogger('myapp.area1')

It results in the foll error :

lne 86, in __init__
    rotatingHandler.doRollover()
  File "c:\python24\lib\logging\handlers.py", line 131, in doRollover
    os.rename(self.baseFilename, dfn)
OSError: [Errno 13] Permission denied
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "c:\python24\lib\atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "c:\python24\lib\logging\__init__.py", line 1351, in shutdown
    h.flush()
  File "c:\python24\lib\logging\__init__.py", line 731, in flush
    self.stream.flush()
ValueError: I/O operation on closed file
Error in sys.exitfunc:
Traceback (most recent call last):
  File "c:\python24\lib\atexit.py", line 24, in _run_exitfuncs
    func(*targs, **kargs)
  File "c:\python24\lib\logging\__init__.py", line 1351, in shutdown
    h.flush()
  File "c:\python24\lib\logging\__init__.py", line 731, in flush
    self.stream.flush()
ValueError: I/O operation on closed file

Can anyone tell me, w hat is wrong with my code.

Roopesh




More information about the Python-list mailing list