Gunicorn access logging is broken
See original GitHub issueHi all,
I originally found out about this bug which I was affected by here: https://github.com/tiangolo/uvicorn-gunicorn-starlette-docker/issues/1
Description
When using Gunicorn deployed with --access-logfile
set and using the -k uvicorn.workers.UvicornWorker
option, no access logs are sent to the access log file. Note that access logs do get sent to error logger (gunicorn.error
) but they are supposed to go to access logger (gunicorn.access
)
The Problem in Code
The issue is due to the following in httptools_impl.py
:
The problem is self.logger
references a gunicorn logger: https://github.com/benoitc/gunicorn/blob/dc7b5d5c4876b49f86ea2460698a335d0f5ef7c9/gunicorn/glogging.py#L166 and the methods for logging there are only for the error logger (see the definition for the info
method).
To use the access logger it would have to be self.logger.access_log.info(...)
instead. I’ve confirmed this by making those changes manually and running the same gunicorn config and it fixes it. I believe hardcoding that piece will break the logging done by running uvicorn
directly so I have not attached a PR. I am still looking into it, but if anyone has a good fix please go ahead.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Top GitHub Comments
hello, is there an ETA for this fix? Also will the gunicorn access log format setting be honored?
Is there a separate issue for the access log format? I can enable and disable access logs using
accesslog
ingunicorn_conf.py
, but not change the log format withaccess_log_format
.