Created
March 24, 2019 08:18
-
-
Save guillermo-carrasco/06ed53ec7f0e98e314cc2bb348be7a8f to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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