Created
March 14, 2016 16:42
-
-
Save amatthies/b014ca1d3f67acd53b0b to your computer and use it in GitHub Desktop.
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 json | |
import logging | |
import logging.config | |
with open('python-logging.json', 'r') as f: | |
logging.config.dictConfig(json.load(f)) | |
logger = logging.getLogger(__name__) | |
logger.info("Logging config loaded from json") | |
logger.debug("This is a DEBUG message on the logger.") | |
logger.info("This is an INFO message on the logger.") | |
logger.warning("This is a WARNING message on the child logger.") | |
logger.error("This is an ERROR message.") |
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, | |
"disable_existing_loggers": "False", | |
"formatters": { | |
"brief": { | |
"class": "logging.Formatter", | |
"format": "{levelname:7} - {asctime} - {name} - {message}", | |
"style": "{" | |
}, | |
"simple": { | |
"class": "logging.Formatter", | |
"format": "{levelname:7} - {asctime},{msecs:03,.0f} - {name:12} - {message}", | |
"style": "{", | |
"datefmt": "%H:%M:%S" | |
}, | |
"multi-process": { | |
"class": "logging.Formatter", | |
"format": "%(levelname)-4s - %(asctime)s - %(name) - [%(process)d] - %(message)s" | |
}, | |
"multi-thread": { | |
"class": "logging.Formatter", | |
"format": "%(levelname)-4s; %(asctime)s; %(name)-15s; [%(threadName)s]; %(message)s" | |
}, | |
"verbose": { | |
"class": "logging.Formatter", | |
"format": "%(levelname)-4s; %(asctime)s; %(name)-15s; [%(process)d]; %(threadName)s; %(message)s" | |
}, | |
"multiline": { | |
"class": "logging.Formatter", | |
"format": "thread: %(threadName)s\nLevel: %(levelname)s\nTime: %(asctime)s\nLocation: %(pathname)s:%(lineno)d\nMethod: %(funcName)s\nMessage:\n%(message)s\n" | |
} | |
}, | |
"handlers": { | |
"console": { | |
"level": "DEBUG", | |
"class": "logging.StreamHandler", | |
"formatter": "simple", | |
"stream": "ext://sys.stdout" | |
} | |
}, | |
"loggers": { | |
"botocore": { | |
"level": "WARNING", | |
"handlers": [ | |
"console" | |
], | |
"propagate": "no" | |
} | |
}, | |
"root": { | |
"handlers": [ | |
"console" | |
], | |
"level": "DEBUG" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment