Created
February 28, 2018 01:51
-
-
Save YakBarber/82afbec945105418cf88204f8f78ab95 to your computer and use it in GitHub Desktop.
Prevent werkzeug from overriding your own logging handlers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Werkzeug only checks the root logger for user-created handlers before setting its own. | |
#Since the correct way to create module-wide logging is _not_ with the root logger, this | |
#causes werkzeug to set its own logger over top of any you may create. | |
#This can be solved by setting the level of the 'werkzeug' logger to > 0 before werkzeug | |
#is started. It can also be solved by adding a handler to the root logger. But the consensus | |
#is that you should not do that. Do this: | |
import logging | |
#somewhere before app.run | |
wlog = logging.getLogger("werkzeug") | |
wlog.setLevel(logging.DEBUG) #anything other than logging.NOTSET | |
wlog.addHandler(your_handler) | |
wlog.addHandler(your_other_handler) | |
#whatever else |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment