Closed slowchen closed 2 years ago
Hi!
This is probably a question you should ask over at loguru
, since it is not really related to this package. I am not a loguru
user, and I'm not sure why you have to write logger.remove()
, but this is the source of your problem. Remove that line and the log is printed. Uvicorn
also takes log arguments, so maybe you should look into that?
I'll close this issue, but we'll still get notified if you reply in it. Have a good weekend 😊
Thank you for your answer. And according to your picture, why is there no correlation id in the start app output log
The correlation ID is generated when a request is done to FastAPI, and then that ID attached to all other log messages for that request. In other words, if there is just a normal log that is not triggered through a request, it won’t have a correlation ID. Using loguru it seems to be completely gone, normally it would be None
.
OK, I probably understand what you mean. This may be the problem of loguru. If you use python logging, even normal log can be printed success. Is that right?
I mean, the ID is generated on an incoming request. So any log generated on startup/shutdown is not triggered by an incoming request, and won’t have an ID.
I see. Thank you very much for your reply. Have a nice weekend
You’re welcome. Thank you, you too!😊
I configured loguru in fastapi according to the example, and the code is as follows.
After the project is started, logger did not print the log in
start_app()
, justprint()
How can I configure it to print the log correctly when fastapi, startup or adding middleware