Support disabling logs #15
Replies: 5 comments 1 reply
-
| This would be funny if it weren't so sad. FastAPI positions itself as a high-performance framework, but its nice ‘rich’ output cannot be disabled or redirected to a file (or null) in Windows. With one line   | 
Beta Was this translation helpful? Give feedback.
-
| I am having some trouble with this subject too. I have an implementation that is based on this gist, and after changing to use  What I want to do is basically the same that I was doing with unicorn using the lines bellow: logging.getLogger("uvicorn.access").handlers.clear()
logging.getLogger("uvicorn.access").propagate = FalseDoes anyone know if this is possible? | 
Beta Was this translation helpful? Give feedback.
-
| By default, the  While it is possible to disable "runtime" logs using # Clear custom rich handlers of uvicorn and uvicorn.access
logging.getLogger("uvicorn.access").handlers.clear() 
logging.getLogger("uvicorn").handlers.clear()
# Option A: disable propagation of all uvicorn logs
logging.getLogger("uvicorn").propagate = False
# Option B: propagate uvicorn logs to root logger
logging.getLogger("uvicorn.access").propagate = True # Does not propagate by defaultIt is not possible to disable the start up logs that appear immediately after running  | 
Beta Was this translation helpful? Give feedback.
-
| Any update on this? We really need this so we can stop poisoning our log analytics 😃 | 
Beta Was this translation helpful? Give feedback.
-
| An update would be nice. Structured logging is pretty essential for any production environment (e.g. Kibana, Splunk, Datadog). The easy way would be to pass the flag to uvicorn just to mimic functionality: But it would be incredibly nice for popular powerful 3rd party logging libraries like loguru and structlog to work seamlessly with FastAPI-CLI. So I understand that disabling it entirely feels like it should be an option. 
 But perhaps, if possible, making it a callable setup would be even more baller: 
 | 
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Hello,
I would like to be able to disable the CLI's logs, mostly the panels when it starts.
The cherry-on-top would be to be able to disable uvicorn's logs too ("Uvicorn running on ...").
Ideally it could be configured with environment variables.
Thank you
Operating System
macOS
Operating System Details
14.4.1 on M3 Max
Python Version
3.12.3
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions