Logging patterns

Standard library logging

Logging

Django logging configuration

Defined loggers:

  • <catch all>
  • django
  • django.startup
  • django.request
  • django.db.backends
  • django.commands
  • django.security.DisallowedHost
  • app.* - for project app loggers
  • boto
  • celery
  • requests
  • raven
  • sentry.errors

Defined handlers:

  • mail_admins
  • console
  • console_celery
  • sentry
class common_configs.logging.stdlib.Logging
LOGGING_DEFAULT_HANDLER = Value: 'console'

Env variable: DJANGO_LOGGING_DEFAULT_HANDLER

Default handler

LOGGING_CELERY_HANDLER = Value: 'console_celery'

Env variable: DJANGO_LOGGING_CELERY_HANDLER

Default handler for celery

LOGGING_DEFAULT_FORMATTER = Value: 'console'

Env variable: DJANGO_LOGGING_DEFAULT_FORMATTER

Default formatter

LOGGING_ADD_REQUEST_ID = Value: True

Env variable: DJANGO_LOGGING_ADD_REQUEST_ID

Add request-id to each log line (requires https://github.com/dabapps/django-log-request-id)

LOGGING_USE_SENTRY = Value: True

Env variable: DJANGO_LOGGING_USE_SENTRY

Use sentry for error logging

LOGGING()

Fully configured Django logging

Structlog logging

Enables structlog.org logging.

StructLoggingDev

class common_configs.logging.structlog.StructLoggingDev
STRUCTLOG_CONFIGURED

StructLoggingProd

class common_configs.logging.structlog.StructLoggingProd
STRUCTLOG_CONFIGURED
Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.