Proper way to delete/kill a logger?

cassiope fpm at u.washington.edu
Sun Nov 27 23:16:43 EST 2011


I've been trying to migrate some code to using the standard python
logging classes/objects.  And they seem quite capable of doing what I
need them to do.  Unfortunately there's a problem in my unit tests.
It's fairly common to have to create quite a few entities in the
course of a series of tests.  What appears to be happening is that the
loggers don't get entirely eliminated, so that new invocations end up
spewing output messages from each of the loggers that were started
with this invocation of the python interpreter.

I haven't found a function within the logging module that completely
kills a given instance.  The removeHandler() function seems to leave a
stdout/stderr output even if all the assigned handlers have been
removed.  I've tried a few workarounds, such as increasing the level
to an absurdly large level, which mostly kinda works, and killing the
old entity before creating the new test version.

There is probably something simple that I'm missing.  If you know what
that is, please point me to that fine manual - I'd appreciate it.
Thanks!

    -f



More information about the Python-list mailing list