How to list all existing loggers using python.logging module

Loggers are held in a hierarchy by a logging.Manager instance. You can interrogate the manager on the root logger for the loggers it knows about.

import logging

loggers = [logging.getLogger(name) for name in logging.root.manager.loggerDict]

Calling getLogger(name) ensures that any placeholder loggers held by loggerDict are fully initialized when they are added to the list.

Leave a Comment