Yup, the default logger is the root logger ''
, you can get it via:
Note the different type:
>>> logging.getLogger('')
<logging.RootLogger object at 0x7f0b9521ec18>
in Django you can add handlers to the root logger easily:
LOGGING = {
...
'loggers': {
'': {
'level': 'DEBUG',
'handlers': ['system_log', 'debug_log', 'sentry'],
},
},
}
If you attach a handler to the root logger, it will see ALL the logs. This is not always wanted. So if you attach some handlers to a more specialised logger, you can then set the other one to propagate=False
so that the message doesn't reach the root logger.
'loggers': {
'': {
'level': 'DEBUG',
'handlers': ['system_log', 'debug_log', 'sentry'],
},
'django': {
'level': 'INFO',
'handlers': ['another_handler_just_for_django'],
'propagate': False,
},
},