New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging not working propperly with django application in gunicorn 19.x #1244

Closed
mannysz opened this Issue Apr 14, 2016 · 8 comments

Comments

Projects
None yet
2 participants
@mannysz
Copy link

mannysz commented Apr 14, 2016

Hello guys,
We are running in trouble to log properly the access and error log.

Take a look on this stackoverflow thread (8 months open and no solution):
http://stackoverflow.com/questions/31755087/cant-get-logging-to-file-to-work-in-gunicorn-19-x-works-in-version-18

It works properly on gunicorn 18, and no way to work in gunicorn 19+.

Here is my django logging configuration:
https://gist.github.com/emanuelcds/337791401692b681455311ee932c1113

I'm running gunicorn with this command line:

$ gunicorn contentools.wsgi:application --workers 8 -b unix:/tmp/gunicorn.sock --access-logfile /var/log/web.access.log --error-logfile /var/log/web.error.log

Double checked and all file permissions are ok and owned by gunicorn user.

@tilgovi

This comment has been minimized.

Copy link
Collaborator

tilgovi commented Apr 19, 2016

What happens if, instead of passing access-logfile and error-logfile, you pass no logging options to Gunicorn and set up logging entirely through Django.

Tell Django to disable existing loggers and define the gunicorn.error and gunicorn.access logs there to your liking?

@tilgovi

This comment has been minimized.

Copy link
Collaborator

tilgovi commented Apr 19, 2016

Sorry, my comment is useless. I'm investigating. I need to understand more how Django sets up logging.

@tilgovi

This comment has been minimized.

Copy link
Collaborator

tilgovi commented Apr 19, 2016

@emanuelcds Gunicorn used to redirect stdout and stderr to its error log file, but that is not supported anymore.

If you're seeing a problem where gunicorn stops writing to its error log when you see application logs in your file handler, add disable_existing_loggers: False.

@tilgovi

This comment has been minimized.

Copy link
Collaborator

tilgovi commented Apr 19, 2016

This was called out in the changelog, but regrettably probably much more clearly.

http://docs.gunicorn.org/en/stable/2014-news.html:

fix logging: don’t try to redirect stdout/stderr to the logfile.

Very sorry for the confusion. I'll close this bug, but please re-open if you think there is a defect and I have misunderstood your issue.

@tilgovi tilgovi closed this Apr 19, 2016

@mannysz

This comment has been minimized.

Copy link

mannysz commented Apr 20, 2016

Hey @tilgovi thank you for the explanation.
Actually its already set to False, and not working yet.
I will debug it and find by any luck what I missed.

@tilgovi

This comment has been minimized.

Copy link
Collaborator

tilgovi commented Apr 20, 2016

No problem. If you get stuck, please comment and elaborate and let us know
what behavior exactly you expect and what you're seeing. I tried to answer
the SO post, too, but not actually sure it's the same as your issue.

On Tue, Apr 19, 2016, 17:09 Emanuel de Souza notifications@github.com
wrote:

Hey @tilgovi https://github.com/tilgovi thank you for the explanation.
Actually its already set to False, and not working yet.
I will debug it and find by any luck what I missed.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#1244 (comment)

@tilgovi

This comment has been minimized.

Copy link
Collaborator

tilgovi commented Apr 22, 2016

Looking at this again I think you may just need to move the empty logger key up to a top-level root dict. I was re-reading https://docs.python.org/2/library/logging.config.html#dictionary-schema-details and I had forgotten about that.

@mannysz

This comment has been minimized.

Copy link

mannysz commented Apr 22, 2016

Worked. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment