[issue1436] logging.config.fileConfig, NameError: name 'RotatingFileHandler' is not defined
Marc Abramowitz
report at bugs.python.org
Fri May 18 18:57:13 CEST 2012
Marc Abramowitz <msabramo at gmail.com> added the comment:
I just ran into this issue with Python 2.5 (doesn't seem to be an issue in >= 2.6?) and for the benefit of anyone else, I'm copying the answer from `Vinay's Google Group post <http://groups.google.com/group/comp.lang.python/browse_thread/thread/21be57fae7e9381a>` into this bug, in case the Google group goes away or the URL changes.
The values in the config file are interpreted in the context of the
logging module's namespace. Hence, one way of achieving what you
want is putting any custom handlers in a module of your own, and
providing a binding in the logging module's namespace. For example:
assuming your DBHandler is defined in a module customhandlers, you
could do this somewhere in your code, before loading the
configuration:
import logging
import customhandlers # Use your own module name here
logging.custhandlers = customhandlers # Bind your module to "custhandlers" in logging
and then your logging configuration can refer to
"custhandlers.DBHandler". Of course I merely used "custhandlers" and
"customhandlers" to show how you can bind to an arbitrary name.
----------
nosy: +Marc.Abramowitz
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1436>
_______________________________________
More information about the Python-bugs-list
mailing list