logging error with RotatingFileHandler

flupke flupke at nonexistingdomain.com
Fri Jun 30 08:08:32 EDT 2006


Vinay Sajip schreef:
> flupke wrote:
> 
>> If this bug is fixed, where will i find a fixed version and how do i
>> install it?
>> Also, more important to me, what am i doing wrong to get this error
>> message in the first place?
> 
> You're not doing anything particularly wrong, though it's not exactly
> good practice to call fileConfig lots of times. (It's really meant for
> one-off configuration, not incremental configuration.)
> 
> I get an error with just the following script typed in at the
> interactive prompt:
> 
> import logging.config
> logging.config.fileConfig("logconf.ini")
> logging.config.fileConfig("logconf.ini")
> 
> So, I will investigate, and when I check in a fix to the Python
> Subversion repository, I will post a message to this thread.
> 
> Regards,
> 
> Vinay Sajip
> 

Hi Vinay,

thanks for the info.

I tried to change the handlers.py file.
First, i changed some code in doRollover.

if os.path.exists(dfn):
    os.remove(dfn)
try:
    #os.rename(self.baseFilename, dfn)

-> The rename fails for some reason.

I tried with the move function of shutil
    shutil.move(self.baseFilename, dfn)

This partially works: the file is now rotated but i still get an error:
The error that i get is this:
Error  [Errno 13] Permission denied: 'E:\\python\\proj1\\src\\proj1.log'
Traceback (most recent call last):
  File "C:\Python24\lib\logging\handlers.py", line 72, in emit
    self.doRollover()
  File "C:\Python24\lib\logging\handlers.py", line 141, in doRollover
    self.handleError(record)
NameError: global name 'record' is not defined

The last part of the error shows that the part where the exception is
caugth is also not working correctly as the "record" isn't know.

When i close my program, i get this error as well:

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 1333, in shutdown
    h.close()
  File "C:\Python24\lib\logging\__init__.py", line 772, in close
    StreamHandler.close(self)
  File "C:\Python24\lib\logging\__init__.py", line 674, in close
    del _handlers[self]
KeyError: <logging.handlers.RotatingFileHandler instance at 0x01E098A0>
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 1333, in shutdown
    h.close()
  File "C:\Python24\lib\logging\__init__.py", line 772, in close
    StreamHandler.close(self)
  File "C:\Python24\lib\logging\__init__.py", line 674, in close
    del _handlers[self]
KeyError: <logging.handlers.RotatingFileHandler instance at 0x01E098A0>

Regards
Benedict



More information about the Python-list mailing list