Disable console messages in Flask server

前端 未结 10 800
旧巷少年郎
旧巷少年郎 2020-11-28 07:42

I have a Flask server running in standalone mode (using app.run()). But, I don\'t want any messages in the console, like

127.0.0.1 - - [15/Feb/2         


        
10条回答
  •  感情败类
    2020-11-28 08:24

    @Drewes solution works most of the time, but in some cases, I still tend to get werkzeug logs. If you really don't want to see any of them, I suggest you disabling it like that.

    from flask import Flask
    import logging
    
    app = Flask(__name__)
    log = logging.getLogger('werkzeug')
    log.disabled = True
    app.logger.disabled = True
    

    For me it failed when abort(500) was raised.

提交回复
热议问题