Skip to content

Instantly share code, notes, and snippets.

@hseritt
Created February 25, 2017 12:44
Show Gist options
  • Save hseritt/efdbaba9e8c5e5fca2ebd3489dc4a91a to your computer and use it in GitHub Desktop.
Save hseritt/efdbaba9e8c5e5fca2ebd3489dc4a91a to your computer and use it in GitHub Desktop.
Logging setup for a Django project
...
# Logging settings
LOGGING = {
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt' : "%d-%m-%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'file': {
'level': 'INFO',
'class': 'logging.FileHandler',
'filename': 'logs/activo.log',
'formatter': 'verbose'
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose',
}
},
'loggers': {
'django': {
'handlers':['file'],
'propagate': True,
'level':'WARNING',
},
'apps.common': {
'handlers': ['file', 'console'],
'level': 'INFO',
},
'apps.contacts': {
'handlers': ['file', 'console'],
'level': 'INFO',
},
'activotrack': {
'handlers': ['file', 'console'],
'level': 'WARNING',
},
},
'version': 1,
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment