Last active
August 3, 2016 13:22
-
-
Save dserodio/ed9403f62925f208dd90 to your computer and use it in GitHub Desktop.
Python logging setup
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
import logging | |
logging.basicConfig(level=logging.DEBUG, | |
format='%(asctime)s %(levelname)-.5s %(message)s') | |
logging.getLogger('requests').setLevel(logging.WARN) |
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
import logging | |
logging_config = open('logging.yml') | |
logging.config.dictConfig(yaml.load(logging_config)) | |
logging_config.close() |
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
version: 1 | |
formatters: | |
simple: | |
format: '%(asctime)s %(levelname)-.5s %(message)s' | |
handlers: | |
console: | |
class: logging.StreamHandler | |
level: DEBUG | |
formatter: simple | |
stream: ext://sys.stdout | |
file: | |
class: logging.FileHandler | |
level: DEBUG | |
formatter: simple | |
filename: migrate.log | |
loggers: | |
requests: | |
level: WARN | |
root: | |
level: DEBUG | |
handlers: [console,file] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment