Skip to content

Instantly share code, notes, and snippets.

@cshoe
Created May 22, 2012 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cshoe/2772000 to your computer and use it in GitHub Desktop.
Save cshoe/2772000 to your computer and use it in GitHub Desktop.
Python Logging DictConfig
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'basic': {
'format': '%(asctime)-6s: %(name)s - %(levelname)s - %(message)s',
}
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'basic',
},
'main_file': {
'level': 'INFO',
'class': 'logging.handlers.WatchedFileHandler',
'formatter': 'basic',
'filename': os.path.join(LOG_PATH, 'main.log'),
},
'error_file': {
'level': 'ERROR',
'class': 'logging.handlers.WatchedFileHandler',
'formatter': 'basic',
'filename': os.path.join(LOG_PATH, 'error.log'),
}
},
'loggers': {
'foo.bar': {
'handlers': ['console', 'main_file', 'error_file'],
'level': 'DEBUG',
'propogate': True
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment