When running under gunicorn, --access-logformat isn't honored.
There was some discussion of this in #389, but I didn't see an open issue for it.
This is a pretty big loss for observability for us, and means we have to implement something out of band (and therefore less efficient). Any word on if it will be worked on?
Any update on this?
Any update on this one?
Hey folks - "Any update on this" is almost always not helpful. If there was an update on it, it'd be here on the ticket.
If anyone wants to put some work into progressing it that'd be welcome.
@tomchristie I would be willing to take a stab. i've taken a look at the code and it seems like the UvicornWorker is fundamentally written in a different way than the rest of the gunicorn workers that come bundled by default.
We would basically need to thread through the Logger instance from gunicorn and call the access method when the request is complete in httptools_impl/h11_impl. We'd also need to record request time which the app currently does not do.
Does this approach sound somewhat correct to you?
@tomchristie just following up to see if my above comment made sense.
We have the same problem at the moment and are about to write a custom logging engine for this, because we must be able to alter the uvicorn log format when running it from gunicorn. Any update on this if there will be a fix? In addition, ideally it should also be configurable in a logging.conf:
[formatter_AccessFormatter]
format=|| %(levelname)s || %(message)s
datefmt=%Y-%m-%dT%H:%M:%S
class=logging.Formatter
access_log_format = %(h)s %(l)s %(u)s %(t)s %(r)s %(s)s %(b)s %(f)s %(a)s
Most helpful comment
@tomchristie I would be willing to take a stab. i've taken a look at the code and it seems like the
UvicornWorkeris fundamentally written in a different way than the rest of the gunicorn workers that come bundled by default.We would basically need to thread through the
Loggerinstance from gunicorn and call theaccessmethod when the request is complete inhttptools_impl/h11_impl. We'd also need to record request time which the app currently does not do.Does this approach sound somewhat correct to you?