Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Django logging with gunicorn

I have a Django 1.6 site running with gunicorn, managed by supervisor. During tests and runserver I have logging on the console, but with gunicorn the statements don't show up anywhere (not even ERROR level logs). They should be in /var/log/supervisor/foo-stderr---supervisor-51QcIl.log but they're not. I have celery running on a different machine using supervisor and its debug statements show up fine in its supervisor error file.

Edit: Running gunicorn in the foreground shows that none of my error messages are being logged to stderr like they are when running manage.py. This is definitely a gunicorn problem and not a supervisor problem.

like image 488
Seán Hayes Avatar asked Jan 24 '14 18:01

Seán Hayes


1 Answers

I got a response on GitHub:

https://github.com/benoitc/gunicorn/issues/708

Since you have passed disable_existing_loggers the Gunicorn loggers are disabled when Django loads your logging configuration. If you are setting this because you want to disable some default Django logging configuration, make sure you add back the gunicorn loggers, gunicorn.error and gunicorn.access with whatever handlers you want.

like image 88
Seán Hayes Avatar answered Sep 30 '22 18:09

Seán Hayes