3

I am integrating Sentry into my Django project for logging errors, and the starter logging config they recommend starts like this:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': True,
    'root': {
        'level': 'WARNING',
        'handlers': ['sentry'],
    },
    ...
}

now, I am used to listing my loggers and assigning handlers in the "logging" key like this:

'loggers': {
    '': {
        'handlers': ['console', 'mail_admins'],
        'level': 'INFO',
    },
}

This way I capture output from all loggers (the name '' captures all) and control my handlers.

But what does putting the root key in do to the logging hierarchy? I couldn't find the answer in the python docs.

From what I've seen it just disables all my tuned loggers with the single sentry logger. I stop seeing my errors in the console, etc.

However if I ignore the sentry root advice and just add the logger over here

'loggers': {
    '': {
        'handlers': ['console', 'mail_admins', 'sentry'],
        'level': 'INFO',
    },
}

All my three loggers start working together in harmony.

So I don't get the root thing. What does it do?

kurtgn
  • 8,140
  • 13
  • 55
  • 91

1 Answers1

2

root - this will be the configuration for the root logger. Processing of the configuration will be as for any logger, except that the propagate setting will not be applicable.

docs

some more info also stackoverflow

Druta Ruslan
  • 7,171
  • 2
  • 28
  • 38