[issue1436] logging.config.fileConfig, NameError: name 'RotatingFileHandler' is not defined
sebastian
report at bugs.python.org
Tue Nov 13 13:41:46 CET 2007
New submission from sebastian:
fileConfig crashes with a NameError when trying to configure a
RotatingFileHandler (I assume the same holds for other handlers defined
in logging.handlers). Using StreamHandler (from the logging package)
works fine. Most likely, I am missing something here, but if not, this
is a really bad joke...
RotatingFileHandler is available on my system, a qualified name must be
used:
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> import logging.handlers
>>> RotatingFileHandler("test.log", "a", 5000, 5)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'RotatingFileHandler' is not defined
>>> logging.handlers.RotatingFileHandler("test.log", "a", 5000, 5)
<logging.handlers.RotatingFileHandler instance at 0x7940d0>
fileConfig crashes, with or without qualified names:
>>> import logging.config
>>> logging.config.fileConfig("test.ini")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/logging/config.py",
line 84, in fileConfig
handlers = _install_handlers(cp, formatters)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/logging/config.py",
line 149, in _install_handlers
klass = eval(klass, vars(logging))
File "<string>", line 1, in <module>
NameError: name 'RotatingFileHandler' is not defined
>>> logging.config.fileConfig("test.qualified_name.ini")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/logging/config.py",
line 84, in fileConfig
handlers = _install_handlers(cp, formatters)
File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/logging/config.py",
line 149, in _install_handlers
klass = eval(klass, vars(logging))
File "<string>", line 1, in <module>
NameError: name 'logging' is not defined
test.ini (in configurationFiles.zip):
---
[loggers]
keys=root
[handlers]
keys=fileHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=DEBUG
handlers=fileHandler
[handler_fileHandler]
class=RotatingFileHandler
level=DEBUG
formatter=simpleFormatter
args=('test.log', 'a', 5000000, 5)
[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=
---
test.qualified_name.ini (in configurationFiles.zip):
---
[loggers]
keys=root
[handlers]
keys=fileHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=DEBUG
handlers=fileHandler
[handler_fileHandler]
class=logging.handlers.RotatingFileHandler
level=DEBUG
formatter=simpleFormatter
args=('test.log', 'a', 5000000, 5)
[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(message)s
datefmt=
---
----------
components: Library (Lib)
files: configurationFiles.zip
messages: 57448
nosy: sebastian
severity: urgent
status: open
title: logging.config.fileConfig, NameError: name 'RotatingFileHandler' is not defined
type: crash
versions: Python 2.5
Added file: http://bugs.python.org/file8740/configurationFiles.zip
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1436>
__________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: configurationFiles.zip
Type: application/zip
Size: 670 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-bugs-list/attachments/20071113/0d974e31/attachment.zip
More information about the Python-bugs-list
mailing list