Skip to content

Instantly share code, notes, and snippets.

@roma-guru
Last active May 4, 2018 11:59
Show Gist options
  • Save roma-guru/16ecda6948611e91c4d704e48c6f337c to your computer and use it in GitHub Desktop.
Save roma-guru/16ecda6948611e91c4d704e48c6f337c to your computer and use it in GitHub Desktop.
Simpliest Django logging (from High Performance Django book)
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'level': 'INFO',
'class': 'logging.StreamHandler',
'formatter': 'simple',
},
'file-debug': {
'level': 'DEBUG',
'class': 'logging.FileHandler',
'formatter': 'verbose',
'filename': 'logs/debug.log',
},
'file-info': {
'level': 'INFO',
'class': 'logging.FileHandler',
'formatter': 'simple',
'filename': 'logs/info.log',
}
},
'formatters': {
'verbose': {
'format': ('%(asctime)s [%(process)d] [%(levelname)s] ' + 'pathname=%(pathname)s lineno=%(lineno)s '
+ 'funcname=%(funcName)s %(message)s '),
'datefmt': '%Y-%m-%d %H:%M:%S',
},
'simple': {
'format': '%(levelname)s %(message)s',
},
},
'loggers': {
'': {
'handlers': ['console', 'file-info', 'file-debug'],
'level': 'DEBUG',
'propagate': True,
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment