I've got a website built with Flask and running on gunicorn behind Nginx. When I run gunicorn manually using the following command
gunicorn --worker-class eventlet -b 127.0.0.1:5000 app:app
I would expect all output, including errors, to be logged to the terminal. But when I visit one specific page which produces a 500 response in the browser, one line in my nginx_access.log
says this:
83.161.xx.xx - - [29/May/2016:15:33:12 +0000] "GET /invites HTTP/1.1" 500 291 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36"
but I get no output for this 500 from the running gunicorn instance. This makes it virtually impossibly to debug the error.
So I tried running gunicorn with supervisord in which I've got gunicorn defined as follows:
[program:gunicorn]
command=/home/immoprod/thesite/venv/bin/gunicorn --worker-class eventlet -b 127.0.0.1:5000 app:app
directory=/home/immoprod/thesite
autostart=true
autorestart=true
stdout_logfile=/home/immoprod/logs/gunicorn_access.log
stderr_logfile=/home/immoprod/logs/gunicorn_error.log
stopsignal=QUIT
The weird thing is that I've got a beta-server with the same setup, in which gunicorn does log errors correctly. As far as I know nothing is different between the two setups (there must be of course, but I wouldn't know what).
Does anybody know why the error output from the 500 internal server error is not logged to stderr by Gunicorn? All tips are welcome!
If it matters: I'm using gunicorn version 18.0
Turns out that I forgot that if in production mode, the application logs errors to another application specific log file.
Maybe this serves as a reminder for future people to check application-specific logs.. :-)