1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to add timestamp to each request in uvicorn logs?

Discussão em 'Python' iniciado por Stack, Setembro 7, 2025.

  1. Stack

    Stack Membro Participativo

    When I run my FastAPI server using uvicorn:

    uvicorn main:app --host 0.0.0.0 --port 8000 --log-level info


    The log I get after running the server:

    INFO: Started server process [405098]
    INFO: Waiting for application startup.
    INFO: Connect to database...
    INFO: Successfully connected to the database!
    INFO: Application startup complete.
    INFO: Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
    INFO: 122.179.31.158:54604 - "GET /api/hello_world?num1=5&num2=10 HTTP/1.1" 200 OK


    How do I get the time stamp along with the request logging? Like:

    INFO: "2020-07-16:23:34:78" - 122.179.31.158:54604 - "GET /api/hello_world?num1=5&num2=10 HTTP/1.1" 200 OK

    Continue reading...

Compartilhe esta Página