0

How can I remove all the messages from the console that flask logs.

For a quick note, I tried:

import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
app.logger.disabled = True
log.disabled = True

But it only prevents the request logs not the server start.

  • 1
    Does this answer your question? [Disable console messages in Flask server](https://stackoverflow.com/questions/14888799/disable-console-messages-in-flask-server) – sahasrara62 Apr 23 '20 at 14:12
  • If you don't want to see that warning, you could *"Use a production WSGI server instead."* – jonrsharpe Apr 23 '20 at 14:13

2 Answers2

2

Here's a working sample:

from flask import Flask
app = Flask(__name__)

import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)
app.logger.disabled = True
log.disabled = True

@app.route("/")
def hello():
    return "Hello World!"

if __name__ == "__main__":
    app.run()
ROUBINSKI
  • 549
  • 4
  • 13
0

This should work:

import logging    
logging.getLogger('werkzeug').disabled = True

But please do use a production server like uwsgi with something in front of it, like nginx.

masnun
  • 10,986
  • 4
  • 37
  • 48