Skip to content

Instantly share code, notes, and snippets.

@adamchainz
Created February 10, 2022 22:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamchainz/efd465f267ad048b04cdd2056058c4bd to your computer and use it in GitHub Desktop.
Save adamchainz/efd465f267ad048b04cdd2056058c4bd to your computer and use it in GitHub Desktop.
Django logging setting with Rich
LOGGING = {
"version": 1,
"disable_existing_loggers": False,
"filters": {
"require_debug_true": {
"()": "django.utils.log.RequireDebugTrue",
},
},
"formatters": {
"rich": {"datefmt": "[%X]"},
},
"handlers": {
"console": {
"class": "rich.logging.RichHandler",
"filters": ["require_debug_true"],
"formatter": "rich",
"level": "DEBUG",
"rich_tracebacks": True,
"tracebacks_show_locals": True,
},
},
"loggers": {
"django": {
"handlers": [],
"level": "INFO",
},
},
"root": {
"handlers": ["console"],
"level": "INFO",
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment