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
@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.