Skip to content

Instantly share code, notes, and snippets.

@anuragrana
Last active December 10, 2017 09:33
Show Gist options
  • Save anuragrana/151129fb715980dfdef52ca464825087 to your computer and use it in GitHub Desktop.
Save anuragrana/151129fb715980dfdef52ca464825087 to your computer and use it in GitHub Desktop.
Simplest Logger settings for Django project
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'large': {
'format': '%(asctime)s %(levelname)s %(process)d %(pathname)s ' +
'%(funcName)s %(lineno)d %(message)s '
}
},
'handlers': {
'errors_file': {
'level': 'ERROR',
'class': 'logging.handlers.TimedRotatingFileHandler',
'when': 'midnight',
'interval': 1,
'filename': os.path.join(BASE_DIR, 'logs/ErrorLoggers.log'),
'formatter': 'large',
},
'info_file': {
'level': 'INFO',
'class': 'logging.handlers.TimedRotatingFileHandler',
'when': 'midnight',
'interval': 1,
'filename': os.path.join(BASE_DIR, 'logs/InfoLoggers.log'),
'formatter': 'large',
},
},
'loggers': {
'error_logger': {
'handlers': ['errors_file'],
'level': 'WARNING',
'propagate': False,
},
'info_logger': {
'handlers': ['info_file'],
'level': 'INFO',
'propagate': False,
},
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment