Skip to content

Gunicorn swallowing exceptions #1051

@pikeas

Description

@pikeas

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 = '-'

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions