-
-
Save daryltucker/e40c59a267ea75db12b1 to your computer and use it in GitHub Desktop.
# I have my own logging setup and had a hard time disabling console output in Flask. | |
app.logger.disabled = True | |
log = logging.getLogger('werkzeug') | |
log.disabled = True | |
# New, 2022 Method: | |
logging.getLogger('werkzeug').disabled = True |
What is 'cf'?
What is 'cf'?
import logging
app.logger.disabled = True
log = logging.getLogger('werkzeug')
log.disabled = True
It dosn't work fo me
It doesn't work for me either.
This was used back in maybe 2012 and published in 2014. Sorry to any users who are having issues w. it in 2021+ no longer working. If anybody provides an update, I can update the gist. Thanks.
This works for me :)
i just add the line "logging.getLogger('werkzeug').disabled = True" and worked
Thank you, it worked
For the record, this only disables the logging statements. If you want to disable the console warnings too, you have to monkeypatch the function that does that (see: cs01/gdbgui#425):
import flask.cli
flask.cli.show_server_banner = lambda *args: None
The old hack (os.environ["WERKZEUG_RUN_MAIN"] = "true"
) doesn't work in werkzeug >=2.1.0.
@mconigliaro Man! your code works well! Thanks :)
If using flask-socketio
:
logging.getLogger("werkzeug").disabled = True
logging.getLogger("geventwebsocket.handler").disabled = True
Really nice! I'm using Flask 2.2.3, it works.
Thank you!
This worked perfectly for me.
pasted right below the instantiation line
app = Flask(name)
logging.getLogger('werkzeug').disabled = True
thanks a lot
Great, used this today. Thanks!