Skip to content

Instantly share code, notes, and snippets.

@amitsaha
Created September 18, 2012 03:58
Show Gist options
  • Select an option

  • Save amitsaha/3741168 to your computer and use it in GitHub Desktop.

Select an option

Save amitsaha/3741168 to your computer and use it in GitHub Desktop.
purge_handlers
def purge_handlers():
#shutdown logging subsystem
#Called during application exit or reinitialization, hence OK.
logging.shutdown()
#remove all handlers
for (_, logger) in logging.root.manager.loggerDict.items():
if hasattr(logger, 'handlers'):
for handler in logger.handlers:
logger.removeHandler(handler)
#clear out logging's internal handler list
logging._handlerList = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment