Flask app logger not working when running within gunicorn

后端 未结 5 1140
臣服心动
臣服心动 2021-01-31 17:53

I\'m trying to save application log messages from a very simple flask app in a log file. While this works flawlessly when I\'m running the app with the embedded Flask server, it

5条回答
  •  一个人的身影
    2021-01-31 18:25

    @Auguiwan's answer does explain the origin question, but not talked about how to solve it.@indrajeet 's answer is quite comprehensive and provides a kind of solution. However, they don't solve my related problem.

    My answer mainly tries to help people who get here by searched similar keywords "flask gunicorn log" like me. I find this link is very helpful among related search result https://medium.com/@yoanis_gil/logging-with-docker-part-1-1-965cb5e17165

    The part Gunicorn configuration

    exec gunicorn ${WSGI_MODULE}:${WSGI_APP} \
      --name $NAME \
      --workers $NUM_WORKERS \
      --user=$USER --group=$GROUP \
      --bind=unix:$SOCKFILE \
      --log-level=info \
      --log-file=/dev/stdout
    

    really helps me out. The core configuration is --log-level and --log-file part.
    If you are using supervisored with gunicorn.conf like me, just change related gunicorn.conf file.

提交回复
热议问题