Reputation: 295
I have a gunicorn *config.py and need to add response time to gunicorn access log:
Here's what I have:
...
accesslog = some_path/filename
access_log_format = '%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
...
gunicorn version 19.7.1
Some more details: *config.py didn't contain the seting access_log_format before, and I thought adding it might help, but even after I added and restarted the process, the access log contains the same parameters as before:
<ip> - - [16/Aug/2020:14:11:35 XDT] "POST /ws/v1/sessions?userId=<username> HTTP/1.1" 200 537 "-" "python-requests/2.22.0"
<ip> - - [16/Aug/2020:14:11:56 XDT] "DELETE /ws/v1/sessions HTTP/1.1" 200 139 "-" "python-requests/2.22.0"
<ip> - - [17/Aug/2020:04:05:40 XDT] "GET /ws/v1/data-specs HTTP/1.1" 200 35097 "-" "python-requests/2.22.0"
<ip> - - [17/Aug/2020:09:30:31 XDT] "GET /ws/v1/data-specs HTTP/1.1" 200 35097 "-" "python-requests/2.22.0"
I am new to python, gunicorn and web apis. I am unable to figure out how to add response time to the log. What am I doing wrong here? Please help.
Upvotes: 5
Views: 4621
Reputation: 1208
From the documentation (https://docs.gunicorn.org/en/stable/settings.html#access-log-format)
The corresponding value for response time miliseconds is %(D)s
Upvotes: 7