I have an application the sets up the logging using:
logging.basicConfig(level=logging_level, format=format_string, filename=log_file, filemode='a')
then call
logging.debug("My Message")
etc. to log messeages. This work fine in most of my application, but then for a particular module I get this error
File "C:\path\to\my\module\MyModule.py", line 53, in __init__
logging.debug("__init__ called")
File "C:\Python26\Lib\logging\__init__.py", line 1481, in debug
root.debug(*((msg,)+args), **kwargs)
File "C:\Python26\Lib\logging\__init__.py", line 1035, in debug
if self.isEnabledFor(DEBUG):
File "C:\Python26\Lib\logging\__init__.py", line 1242, in isEnabledFor
return level >= self.getEffectiveLevel()
File "C:\Python26\Lib\logging\__init__.py", line 1230, in getEffectiveLevel
while logger:
IndexError: list index out of range
Does anyone have any ideas on what could be causing this? Or where else to look to read up on it. I have already read through the logging module code and the python reference pages
Something seems very wrong with your installation – it’s hard to see how a line like
would generate an
IndexError.So, delete all
.pycand.pyofiles from your system (including in the stdlib folders) and try again. Ensure that none of your modules have the same name as any modules in the standard library.Also, what version of Python are you using, and on which platform?
Update: If you are using embedded in a C++ program, or with C extensions, it’s quite possible that some C or C++ code is clobbering memory, leading to the
IndexErrorin a most unexpected place.Can you reproduce in a pure-Python environment? If not, I fear the problem might be in the C/C++ code. It’s also easier to clobber stuff in multi-threaded environments 🙁