Skip to content

Instantly share code, notes, and snippets.

@hbruno
Created March 6, 2018 16:48
Show Gist options
  • Save hbruno/2d560a8246828ee0d484f3e494341304 to your computer and use it in GitHub Desktop.
Save hbruno/2d560a8246828ee0d484f3e494341304 to your computer and use it in GitHub Desktop.
Logging configuration
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 %(asctime)s %(module)s %(message)s'
},
},
'handlers': {
...
'migration': {
'class': 'logging.handlers.RotatingFileHandler',
'filename': str(ROOT_DIR.path('migration.log')),
'maxBytes': 1024*1024*5, # 5MB
'backupCount': 10,
'formatter': 'simple'
},
'command': {
'class': 'logging.handlers.RotatingFileHandler',
'filename': str(ROOT_DIR.path('command.log')),
'maxBytes': 1024*1024*5, # 5MB
'backupCount': 10,
'formatter': 'simple'
},
},
'loggers': {
...
'migrations': {
'handlers': ['migration', 'console'],
'level': 'DEBUG',
'propagate': True
},
'commands': {
'handlers': ['command'],
'level': 'INFO',
'propagate': True
},
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment