Skip to content

Instantly share code, notes, and snippets.

@ipartola
Created November 14, 2012 16:06
Show Gist options
  • Save ipartola/4072994 to your computer and use it in GitHub Desktop.
Save ipartola/4072994 to your computer and use it in GitHub Desktop.
Generic Django 1.3 logging settings
# Place this in your Django 1.3+ settings.py file
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'simple': {
'format': '%(asctime)s %(levelname)s %(message)s'
},
'verbose': {
'format': '%(asctime)s %(levelname)s %(module)s %(message)s'
},
},
'handlers': {
'console':{
'level':'DEBUG',
'class':'logging.StreamHandler',
'formatter': 'simple'
},
'web':{
'level':'DEBUG',
'class':'logging.handlers.TimedRotatingFileHandler',
'formatter': 'verbose',
'filename': '/var/log/MY_APP/web.log',
'when': 'D',
'interval': 1,
'backupCount': 14,
},
'cron':{
'level':'DEBUG',
'class':'logging.handlers.TimedRotatingFileHandler',
'formatter': 'verbose',
'filename': '/var/log/MY_APP/cron.log',
'when': 'D',
'interval': 1,
'backupCount': 21,
},
},
'loggers': {
'django': {
'handlers':['web'],
'propagate': False,
'level':'INFO',
},
'django.request': {
'handlers': ['web'],
'level': 'INFO',
'propagate': False,
},
'MY_APP.cron': {
'handlers': ['cron'],
'level': 'INFO',
'propagate': False,
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment