Advertisement

Your Ad could be here. I want to connect my readers to relavant ads. If you have a product targeted at developers, let's talk. [email protected]

Here's my thought on logs with FastAPI and Uvicorn · Issue #1508 · tiangolo/fastapi


Setting an additional log handler to the uvicorn logger for access logs in fastapi was not straightforward, but This post was very helpful.


@app.on_event("startup")
async def startup_event():
    logger = logging.getLogger("uvicorn.access")
    handler = logging.StreamHandler()
    handler.setFormatter(logging.Formatter("%(asctime)s - %(levelname)s - %(message)s"))
    logger.addHandler(handler)

This post was a thought by Waylon Walker see all my thoughts at https://waylonwalker.com/thoughts