Python’s logging framework has a quirk. By default it will log any message that is warning or higher to
stderr. The framework provides a function,
basicConfig(), that can be used to tweak the format, where logs are sent, and what levels should be logged.
The quirk that will get you eventually, though, is once something has been logged, calling
basicConfig() does nothing.
A quick way to reset logging is to check if
logging.root is defined, and clear it out any handlers if it is:
After cleaning out the root handlers, calling
basicConfig() works again.