Created
January 10, 2020 16:45
-
-
Save chilledornaments/7b03cfcbc7d8d81525546a94bf497632 to your computer and use it in GitHub Desktop.
Gunicorn logging with custom values
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 socket | |
from os import environ | |
hostname = socket.gethostname() | |
""" | |
Logging env vars with %({env_var}e)s hasn't worked for me in gunicorn 20.0.4 | |
""" | |
access_one = '%({X-Forwarded-For}i)s %(r)s "%(s)s" "%(b)s" "%(a)s" "%(p)s" "%(D)s"' | |
access_two = '"{}" app={} env={}'.format(socket.gethostname(), environ.get("APP_NAME"), environ.get("ROLLBAR_ENV")) | |
access_log_format = "{} {}".format(access_one, access_two) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment