Flask logging - Cannot get it to write to a file

后端 未结 7 1223
野趣味
野趣味 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 11:55

    The output you see in the console of your app is from the underlying Werkzeug logger that can be accessed through logging.getLogger('werkzeug').

    Your logging can function in both development and release by also adding handlers to that logger as well as the Flask one.

    More information and example code: Write Flask Requests to an Access Log.

提交回复
热议问题