Python 3.12+loggingfunction
logging.getHandlerNames()
handlers
Returns an immutable set of the names of all known handlers. Helps to see what dictConfig has set up.
Syntax
names = logging.getHandlerNames()
The result is a frozenset: the names come in no particular order and nothing can be added. Unnamed handlers, including the one basicConfig() creates, are not listed at all, so an empty set does not mean there are no handlers. Available since 3.12.
Examples
import logging, sys
logging.basicConfig(stream=sys.stdout)
print(logging.getHandlerNames()) # → frozenset()
h = logging.StreamHandler(sys.stdout)
h.name = 'console'
print(logging.getHandlerNames()) # → frozenset({'console'})
See also
Open in the full glossarydocs.python.orgReport an inaccuracy