Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear/reset all configured logging handlers in Python?

Tags:

python

logging

My Situation
There may be one or more configured loggers, but I don't know what their names are.

Requirement
For testing purposes, I need to reconfigure logging handlers that were previously configured to log to stdout with a different format and logging level.

  1. [caveat] I already know how to clear one handler.
  2. [caveat] I would prefer stdlib over 3rd-party libs (pypi, github, et al).
like image 473
bitcycle Avatar asked Dec 13 '12 23:12

bitcycle


1 Answers

print (logging.Logger.manager.loggerDict.keys())

found by digging the sources of logging package

like image 89
nosklo Avatar answered Sep 28 '22 23:09

nosklo