Here is a small application that reproduces my problem:
import fastapi
import logging
import loguru
instance = fastapi.FastAPI()
@instance.on_event("startup")
async def startup_event():
logger = logging.getLogger("mylogger")
logger.info("I expect this to log")
loguru.logger.info("but only this logs")
When I launch this application with uvicorn app.main:instance --log-level=debug
I see this in my terminal:
INFO: Waiting for application startup.
2024-05-02 13:14:45.118 | INFO | app.main:startup_event:28 - but only this logs
INFO: Application startup complete.
Why does only the loguru
logline work, and how can I make standard python logging work as expected?