Created
November 12, 2015 16:37
-
-
Save barend/5773c6dedbc10596d844 to your computer and use it in GitHub Desktop.
Pretty much the same as [carlcarl/python_logging_dict_config][pldc], but doesn't rely on eval().
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
{ | |
"version": 1, | |
"disable_existing_loggers": true, | |
"formatters": { | |
"debug": { | |
"format": "[%(levelname)s][%(asctime)s](%(funcName)s/%(lineno)d) %(message)s", | |
"datefmt": "%Y-%m-%d %H:%M:%S" | |
}, | |
"simple": { | |
"format": "[%(levelname)s][%(asctime)s] %(message)s", | |
"datefmt": "%Y-%m-%d %H:%M:%S" | |
} | |
}, | |
"handlers": { | |
"console": { | |
"level": "DEBUG", | |
"class": "logging.StreamHandler", | |
"formatter": "simple" | |
}, | |
"file": { | |
"level": "DEBUG", | |
"class": "logging.handlers.RotatingFileHandler", | |
"filename": "test.log", | |
"formatter": "simple", | |
"maxBytes": 10485760, | |
"backupCount": 100 | |
} | |
}, | |
"loggers": { | |
"my_app": { | |
"handlers": [ | |
"console", | |
"file" | |
], | |
"level": "INFO", | |
"propagate": false | |
} | |
} | |
} |
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
#!/usr/bin/env python | |
import json | |
from logging.config import dictConfig | |
dictConfig(json.load(file('logging-config.json'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment