Last active
August 11, 2020 14:00
-
-
Save olivx/4b7360f07c9018f2c4de02826d0b084d to your computer and use it in GitHub Desktop.
python json logger
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
python-json-logger = "*" |
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
LOGGING = { | |
"version": 1, | |
"disable_existing_loggers": False, | |
"formatters": { | |
"json": { | |
"()": "pythonjsonlogger.jsonlogger.JsonFormatter", | |
"fmt": "%(asctime)s - %(name)s - %(levelname)s - %(message)s", | |
} | |
}, | |
"handlers": { | |
"stream": { | |
"level": LOG_LEVEL, | |
"formatter": "json", | |
"class": "logging.StreamHandler", | |
}, | |
"gunicorn-file-stream": { | |
"level": LOG_LEVEL, | |
"formatter": "json", | |
"class": "logging.handlers.RotatingFileHandler", | |
"filename": "/var/log/app/gunicorn.log", | |
"maxBytes": 10_000_000, | |
"backupCount": 3, | |
}, | |
"app-file-stream": { | |
"level": LOG_LEVEL, | |
"formatter": "json", | |
"class": "logging.handlers.RotatingFileHandler", | |
"filename": "/var/log/app/app.log", | |
"maxBytes": 10_000_000, | |
"backupCount": 3, | |
}, | |
}, | |
"loggers": { | |
"django": {"handlers": ["stream", "app-file-stream"], "level": LOG_LEVEL}, | |
"gunicorn": { | |
"handlers": ["stream", "gunicorn-file-stream"], | |
"level": LOG_LEVEL, | |
}, | |
"feira": {"handlers": ["stream", "app-file-stream"], "level": LOG_LEVEL}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment