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

Gunicorn swallowing exceptions #1051

Closed
pikeas opened this Issue Jun 18, 2015 · 5 comments

Comments

Projects
None yet
3 participants
@pikeas

pikeas commented Jun 18, 2015

When I I override LOGGING in my Django settings.py, gunicorn swallows exceptions (runserver displays them). If I revert to Django's default LOGGING config, everything works as expected. Here's my LOGGING setup:

LOGGING_CONFIG = None
LOGGING = {
    'version': 1,
    'formatters': {
        'long': {
            'format': "%(asctime)s %(levelname)-8s %(name)s %(message)s",
        },
    },
    'handlers': {
        'stderr': {
            'class': 'logging.StreamHandler',
            'formatter': 'long',
            'level': 'DEBUG',
            'stream': sys.stderr,
        },
    },
    'loggers': {
        '': {
            'handlers': ['stderr'],
            'level': env('LOG_LEVEL', 'INFO'),
        },
    }
}
logging.config.dictConfig(LOGGING)

Is gunicorn hooking into logging in a way that's incompatible with this? Even if that's the case, exceptions are being swallowed (never displayed) by gunicorn, not logging messages.

Here's my gunicorn.conf.py for reference:

bind = "%s:%s" % (env('GUNICORN_IP', '0.0.0.0'), env('GUNICORN_PORT', 8000))
forwarded_allow_ips = '*'
reload = env('GUNICORN_CODE_RELOAD', False)

access_log = '-'
error_log = '-'
@pikeas

This comment has been minimized.

Show comment
Hide comment
@pikeas

pikeas Jun 18, 2015

Solved. The LOGGING dictionary needs disable_existing_loggers: False. This way gunicorn's logging handlers won't be disabled (default when configuring LOGGING).

May be worth a mention in gunicorn's docs?

pikeas commented Jun 18, 2015

Solved. The LOGGING dictionary needs disable_existing_loggers: False. This way gunicorn's logging handlers won't be disabled (default when configuring LOGGING).

May be worth a mention in gunicorn's docs?

@tilgovi

This comment has been minimized.

Show comment
Hide comment
@tilgovi

tilgovi Jun 18, 2015

Collaborator

Absolutely. Let us know where you think it should go, please! Happy to just have you say so or open a PR that closes this issue and we'll merge it. Thanks!

Collaborator

tilgovi commented Jun 18, 2015

Absolutely. Let us know where you think it should go, please! Happy to just have you say so or open a PR that closes this issue and we'll merge it. Thanks!

@pikeas

This comment has been minimized.

Show comment
Hide comment
@pikeas

pikeas Jun 18, 2015

@tilgovi Hm...that's a bit tricky. Based on the current organization of the docs, Settings/Logging doesn't make much sense, as Settings only describes specific options and their usage.

How about adding a new section, Deploying/Django Configuration to mirror the existing Nginx Configuration section? Either that, or an additional note under Deploying/Logging.

pikeas commented Jun 18, 2015

@tilgovi Hm...that's a bit tricky. Based on the current organization of the docs, Settings/Logging doesn't make much sense, as Settings only describes specific options and their usage.

How about adding a new section, Deploying/Django Configuration to mirror the existing Nginx Configuration section? Either that, or an additional note under Deploying/Logging.

@tilgovi

This comment has been minimized.

Show comment
Hide comment
@tilgovi

tilgovi Jun 18, 2015

Collaborator

That sounds okay to me. I would also link to it with a note in the "Django" sub-section of the "Integration" section of "Running Gunicorn" to increase the likelihood that a first-time user discovers it.

Collaborator

tilgovi commented Jun 18, 2015

That sounds okay to me. I would also link to it with a note in the "Django" sub-section of the "Integration" section of "Running Gunicorn" to increase the likelihood that a first-time user discovers it.

@benoitc

This comment has been minimized.

Show comment
Hide comment
@benoitc

benoitc Jun 22, 2015

Owner

I would just put the information in the integration subsection . Deploying is about operations more than configuration. Thoughts?

Owner

benoitc commented Jun 22, 2015

I would just put the information in the integration subsection . Deploying is about operations more than configuration. Thoughts?

@tilgovi tilgovi added this to the 20.0.0 milestone Dec 31, 2015

@benoitc benoitc closed this in 5fa32a6 May 2, 2016

fofanov pushed a commit to fofanov/gunicorn that referenced this issue Mar 16, 2018

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