Using logging
in python always feels like a banging my head against a wall.
I am trying to configure uvicorn logger.
All uvicorn loggers are like uvicorn.*
. I want to modify the formatting to be in sync with what the full application has.
hdl = logging.StreamHandler(sys.stdout)
hdl.setLevel = "DEBUG"
fmt = "%(levelname) [%(name)s] %(asctime)s: %(message)s"
hdl.setFormatter(logging.Formatter(fmt))
logging.basicConfig(format=fmt)
l = logging.getLogger("uvicorn")
l.handlers.clear()
l.addhandler(hdl)
l.setLevel = "DEBUG"
It doesn’t work, i still have the logs in uvicorn’s default format. What other knobs i need to turn on?