[New-bugs-announce] [issue43058] setting a logging Handler name

Brett Cohen report at bugs.python.org
Thu Jan 28 15:17:02 EST 2021

New submission from Brett Cohen <bcohen at livedata.com>:

When using the logging module to add a new handler, the documentation doesn't mention the ability to set the name of the handler. It turns out that it's actually a supported feature by using:


I'd suggest updating the documentation to indicate the ability to set the name of the handler. It'd be very nice if the name was settable in the constructor of the Handler class. This could be done by including an optional `name` argument that defaults to None:

    class Handler(Filterer):
        def __init__(self, level=NOTSET, name=None):
            self._name = name

I noticed the problem when trying to call logging.config.dictConfig with a config which specified a handler (it crashes: `ValueError: No handler found with name 'my_handler'`).

I initially thought to manually alter the _handlers directly since the docs didn't indicate how to set the name. After digging into the source code I found the undocumented `set_name` function.

assignee: docs at python
components: Documentation, Library (Lib)
messages: 385880
nosy: bcohen, docs at python, vinay.sajip
priority: normal
severity: normal
status: open
title: setting a logging Handler name
type: enhancement
versions: Python 3.8

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list