The initial code is valid, but you selected the wrong logger. To get the traceback on the error, you would need to modify the "uvicorn.error"
logger.
Like so:
import logging
log = logging.getLogger("uvicorn.error")
log.setLevel(logging.DEBUG)
Other available default loggers are "uvicorn"
and "uvicorn.access"
, as seen in @TheClockTwsiter's answer. This way you don't need to copy/modify the entire logging configuration. It will also preserve any implicit behavior of the uvicorn logging configuration, if it is ever updated by the dev team.