A minimal logging config for Django

Django uses Python’s builtin logging module to take care of system logging. But I get it… You are not really here for the theory. All you want is to quickly fix a problem with your company’s Django app so you can leave the office for the weekend. Alas, Python’s default log level won’t let you see the dirty details needed to tackle the issue. Well… not until now, at least. Here you go:

# myapp/settings.py

LOGGING = {
  'version': 1,
  'disable_existing_loggers': False,
  'handlers': {
    'console': {
      'class': 'logging.StreamHandler',
    },
  },
  'loggers': {
    # Configure the root logger
    '': {
      'handlers': ['console'],
      'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
    },
  },
}