Skip to content

Instantly share code, notes, and snippets.

@apelliciari
Created May 26, 2013 13:04
Show Gist options
  • Save apelliciari/5652725 to your computer and use it in GitHub Desktop.
Save apelliciari/5652725 to your computer and use it in GitHub Desktop.
logging conf + sentry
.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
# I always add this handler to facilitate separating loggings
'debug_log_file':{
'level': 'DEBUG',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(ROOT_PROJECT_INTERNAL, 'logs', 'debug.log'),
'maxBytes': '16777216', # 16megabytes
'backupCount': 10,
'formatter': 'verbose'
},
'warning_log_file':{
'level': 'WARNING',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(ROOT_PROJECT_INTERNAL, 'logs', 'warning.log'),
'maxBytes': '16777216', # 16megabytes
'backupCount': 10,
'formatter': 'verbose'
},
'django_log_file':{
'level': 'INFO',
'class': 'logging.handlers.RotatingFileHandler',
'filename': os.path.join(ROOT_PROJECT_INTERNAL, 'logs', 'django.log'),
'maxBytes': '16777216', # 16megabytes
'backupCount': 10,
'formatter': 'verbose'
},
},
'loggers': {
'django.request': {
'handlers': ['mail_admins',],
'level': 'ERROR',
'propagate': True,
},
'core': {
'handlers': ['debug_log_file', 'warning_log_file'],
'level': 'DEBUG',
'propagate': True,
}
}
}
# only in the live settings file
RAVEN_CONFIG = {
'dsn': 'https://[email protected]/xxxx',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment