Created
May 23, 2012 20:55
-
-
Save cshoe/2777755 to your computer and use it in GitHub Desktop.
Python dictConfig Logging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEV_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'), | |
}, | |
'requests_main_file': { | |
'level': 'INFO', | |
'class': 'logging.handlers.WatchedFileHandler', | |
'formatter': 'basic', | |
'filename': os.path.join(LOG_PATH, 'requests_main.log'), | |
}, | |
'requests_error_file': { | |
'level': 'ERROR', | |
'class': 'logging.handlers.WatchedFileHandler', | |
'formatter': 'basic', | |
'filename': os.path.join(LOG_PATH, 'requests_error.log'), | |
} | |
}, | |
'loggers': { | |
'foo.bar': { | |
'handlers': ['console', 'main_file', 'error_file'], | |
'level': 'DEBUG', | |
'propogate': False | |
}, | |
}, | |
'root': { | |
'handlers': ['console', 'main_file', 'error_file'], | |
'level': 'DEBUG', | |
} | |
} | |
# no console ouptput | |
PROD_LOGGING = DEV_LOGGING.copy() | |
PROD_LOGGING.update({ | |
'loggers': { | |
'foo.bar': { | |
'handlers': ['main_file', 'error_file'], | |
'level': 'DEBUG', | |
'propogate': False | |
}, | |
}, | |
'root': { | |
'handlers': ['main_file', 'error_file'], | |
'level': 'DEBUG', | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment