Skip to content

Instantly share code, notes, and snippets.

@timhughes
Created October 16, 2013 21:00
Show Gist options
  • Save timhughes/7014771 to your computer and use it in GitHub Desktop.
Save timhughes/7014771 to your computer and use it in GitHub Desktop.
Django RotatingFileHandle example
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'default': {
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(SITE_ROOT, "log", "default.log"),
'maxBytes': 1024 * 1024 * 5, # 5 MB
'backupCount': 5,
# 'formatter':'standard',
},
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'': {
'handlers': ['default'],
'level': 'DEBUG',
'propagate': True
},
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
@timhughes
Copy link
Author

This also looks like a good logging setup . Maybe I integrate it
http://www.miximum.fr/bien-developper/876-an-effective-logging-strategy-with-django

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment