[Python] FastAPI uvicorn not logging errors

Discussão em 'Python' iniciado por Stack, Março 14, 2025.

  1. Stack

    Stack Membro Participativo

    I am learning fastapi, and I am starting a uvicorn server on localhost. Whenever there is an error or an exception, I am not getting the traceback. All I am getting is : INFO: 127.0.0.1:56914 - "POST /create/user/ HTTP/1.1" 500 Internal Server Error

    So, It is difficult to debug, I am trying out logging module of python

    import logging
    log = logging.getLogger("uvicorn")
    log.setLevel(logging.DEBUG)


    I have also tried starting uvicorn with debug parameter

    if __name__ == "__main__":
    dev = 1
    print("printing")
    if dev == 1:
    uvicorn.run('main:app', host="127.0.0.1", port=5000, log_level="info", reload=True, debug=True)
    if dev == 2:
    uvicorn.run('main:app', host="127.0.0.1", port=5000, log_level="info", workers=2)


    still the same problem persists. I am in development phase and I need the error traceback, please guide.

    Continue reading...

Compartilhe esta Página