Skip to content

Instantly share code, notes, and snippets.

@dserodio

dserodio/log.py

Last active Aug 3, 2016
Embed
What would you like to do?
Python logging setup
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)-.5s %(message)s')
logging.getLogger('requests').setLevel(logging.WARN)
import logging
logging_config = open('logging.yml')
logging.config.dictConfig(yaml.load(logging_config))
logging_config.close()
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