Skip to content

Instantly share code, notes, and snippets.

@guillermo-carrasco
Created March 24, 2019 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillermo-carrasco/06ed53ec7f0e98e314cc2bb348be7a8f to your computer and use it in GitHub Desktop.
Save guillermo-carrasco/06ed53ec7f0e98e314cc2bb348be7a8f to your computer and use it in GitHub Desktop.
import yaml
import logging
import logging.config
with open('config.yaml', 'r') as f:
conf = yaml.load(f)
logging.config.dictConfig(conf)
myapp = logging.getLogger('myapp')
myapp.info('This logger will write both to console and to the logging file, since the logger\'s name is myapp')
myapp_api = logging.getLogger('myapp.api')
myapp_api.info('This should also write to both since its a descendant of myapp')
another_logger = logging.getLogger('another_app')
another_logger.info('This instead should only appear in the console')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment