1

I get duplicate logging output for exceptions and errors in my pythong LOGGING confirmation. It makes sense given the configuration:

LOGGING = {
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        },
        'sentry': {
            'level': 'WARNING',
            'class': 'raven.contrib.django.handlers.SentryHandler',
        },
        'console': {
            'level': 'DEBUG',
            'class': 'logging.StreamHandler',
            'formatter': 'verbose'
        },
    },
    'root': {
        'level': 'ERROR',   # Give me errors only
        'handlers': ['mail_admins', 'sentry', 'console'],
    },
    'apps.order_shipping': {
        # This module needs extra debugging, but now ERROR is duplicated
        'handlers': ['console'],
        'level': 'DEBUG',
    },
}

how can I implement this in a better way? I'd like to enable verbosity for some modules, without causing duplication of ERROR messages.

1 Answer 1

3

Set propagate to False:

{
# ...
    'apps.order_shipping': {
        # This module needs extra debugging, but now ERROR is duplicated
        'handlers': ['console'],
        'level': 'DEBUG',
        'propagate': False,
    },
}
Sign up to request clarification or add additional context in comments.

2 Comments

I'm curious, won't this block ERROR messages from being picked up by the root logger? So the only solution is duplicating the list of handlers for all other loggers too?
I've taken the non DRY route of repeating all handlers for all loggers. A shame, but I don't see any other way right now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.