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?