Hi!
This is my Django logging config:
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"}},
"formatters": {
"verbose": {
"format": "%(levelname)s %(asctime)s %(module)s "
"%(process)d %(thread)d %(message)s"
}
},
"handlers": {
"mail_admins": {
"level": "ERROR",
"filters": ["require_debug_false"],
"class": "django.utils.log.AdminEmailHandler",
'include_html': True,
},
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
"formatter": "verbose",
},
"file": {
"class": "logging.FileHandler",
"filename": os.path.join(APPS_DIR + "..", "app.log"),
},
'db_queries': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'filename': os.path.join(APPS_DIR + "..", 'db_queries.log'),
},
},
"root": {
"level": "WARNING",
"handlers": ["file", "mail_admins"],
"propagate": True,
},
"loggers": {
"django.request": {
"handlers": ["file", "mail_admins"],
"level": "ERROR",
"propagate": True,
},
"django.security.DisallowedHost": {
"level": "ERROR",
"handlers": ["file", "mail_admins"],
"propagate": True,
},
"django": {
"handlers": ["file"],
"level": "DEBUG",
"propagate": True,
},
'django.db.backends': {
'level': 'DEBUG',
'handlers': ['db_queries'],
'propagate': False,
},
},
}
The “root” logger works, both for file and mails_admin, but the other loggers don’t seem to do anything. I would expect that at least the “django” and “django.db.backends” handlers would write something to file.
Any ideas what could be the cause?
PS, also on SO: python - Django logging only logs "root", no other handlers - Stack Overflow
Edit: django.db.backends
only works when DEBUG=True
apparently, so that explains that part. I still don’t understand why the “django” logger doesn’t work.