Skip to content

Instantly share code, notes, and snippets.

@palewire
Created February 4, 2012 21:50
Show Gist options
  • Save palewire/1740398 to your computer and use it in GitHub Desktop.
Save palewire/1740398 to your computer and use it in GitHub Desktop.
My current default Django LOGGING configuration
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
},
'null': {
'level':'DEBUG',
'class':'django.utils.log.NullHandler',
},
'console':{
'level':'DEBUG',
'class':'logging.StreamHandler',
'formatter': 'verbose'
},
'logfile': {
'level':'DEBUG',
'class':'logging.handlers.RotatingFileHandler',
'filename': os.path.join(ROOT_PATH, 'django.log'),
'maxBytes': 1024*1024*5, # 5MB
'backupCount': 0,
'formatter': 'verbose',
},
},
'formatters': {
'verbose': {
'format': '%(levelname)s|%(asctime)s|%(module)s|%(process)d|%(thread)d|%(message)s',
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s|%(message)s'
},
},
'loggers': {
'myapp.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'myapp.tasks': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'myapp.management': {
'handlers': ['console', 'logfile'],
'level': 'DEBUG',
'propagate': True,
},
'myapp.models': {
'handlers': ['console', 'logfile'],
'level': 'DEBUG',
'propagate': True,
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment