Last active
February 28, 2018 11:23
-
-
Save MCardus/8a56557693ee453e100a46046e4fa4c8 to your computer and use it in GitHub Desktop.
Python logging conf in YML format for generaing JSON logs
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 | |
formatters: | |
human: | |
format: | | |
{ | |
"name" : "%(name)s", | |
"timestamp" : "%(asctime)s", | |
"severity" : "%(levelname)s", | |
"message" : "%(message)s" | |
} | |
machine: | |
format: > | |
{"name" : "%(name)s", "timestamp" : "%(asctime)s", "severity" : "%(levelname)s", "message" : "%(message)s"} | |
handlers: | |
file_info: | |
class: logging.handlers.RotatingFileHandler | |
level: INFO | |
formatter: machine | |
filename: info.log | |
maxBytes: 10485760 # 10MB | |
backupCount: 20 | |
encoding: utf8 | |
file_error: | |
class: logging.handlers.RotatingFileHandler | |
level: ERROR | |
formatter: machine | |
filename: errors.log | |
maxBytes: 10485760 # 10MB | |
backupCount: 20 | |
encoding: utf8 | |
console: | |
class: logging.StreamHandler | |
level: DEBUG | |
formatter: human | |
stream: ext://sys.stdout | |
loggers: | |
simple: | |
level: DEBUG | |
handlers: [console] | |
propagate: no | |
root: | |
level: DEBUG | |
handlers: [console, file_info, file_error] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment