-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uvicorn - access log format is not working #2299
Comments
I have the same issue, the log format not worked.
and gunicorn.config.py : access_log_format = '[host: %h|pid: %p|timestamp: %t](%H)s (%r)s (%m)s (%U)s referer (%f)s => response %(s)s %(b)s bytes %(D)s' finally, i use the uvicorn access log and redirect stdout/err into gunicorn error log. i config the settings like this to use uvicorn access log:
and set error log and capture output in gunicorn.config.py.
Someone has a better idea ? Because i don't think that's a good way. |
We are working on it. |
@Kludex thank you ! |
There's nothing that Gunicorn can do, this should be solved on uvicorn's side. You can follow this on: encode/uvicorn#527 Feel free to close this issue @benoitc 👀 |
I got the answer. |
Closing as this appears to be a downstream issue with uvicorn. |
For people who using FastAPI, one solution is like this: import logging
from contextlib import asynccontextmanager
from fastapi import FastAPI
LOG_FMT = "%(asctime)s - %(levelname)s - %(message)s"
def config_access_log_to_show_time():
logger = logging.getLogger("uvicorn.access")
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter(LOG_FMT))
logger.addHandler(handler)
@asynccontextmanager
async def lifespan(app: FastAPI):
config_access_log_to_show_time()
yield
app = FastAPI(lifespan=lifespan) |
only for uvicorn ,but not woring gunicorn config. |
the access log format below is not getting printed - and looks like uvicorn worker class is overriding the access log format
%(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s %(D)s %({header}i)s
The text was updated successfully, but these errors were encountered: