I get a regular non-root logger of the default type:
logger = logging.getLogger('a')
Now I want to change the type and get a new logger for the same name:
logging.setLoggerClass(type('NewLoggerClass', (logging.Logger,), {}))
logger = logging.getLogger('a')
I would like the second call to getLogger
to respect the new logger class I set. However, logger
remains the same instance of logging.Logger
instead of __main__.NewLoggerClass
.
How do I either remove an existing logger for a given name, or replace it with one of a different type?