Flask logging - Cannot get it to write to a file

后端 未结 7 1225
野趣味
野趣味 2020-12-04 11:30

Ok, here\'s the code where I setup everything:

if __name__ == \'__main__\':
    app.debug = False

    applogger = app.logger

    file_handler = FileHandler         


        
7条回答
  •  再見小時候
    2020-12-04 12:00

    Ok, my failure stemmed from two misconceptions:

    1) Flask will apparently ignore all your custom logging unless it is running in production mode

    2) debug=False is not enough to let it run in production mode. You have to wrap the app in any sort of WSGI server to do so

    After i started the app from gevent's WSGI server (and moving logging initialization to a more appropriate place) everything seems to work fine

提交回复
热议问题