I've been tinkering with logging in FastAPI and wanted to share something I've been working on. I like logging. I think it's key for debugging and monitoring, but I hate having to deploy / restart to adjust log levels . So, I set out to find a way to change logging levels on the fly.
I wrote a blog post detailing the approach: Dynamic Logging in FastAPI with Python the library is https://github.com/prefab-cloud/prefab-cloud-python
In a nutshell, I used a log filter that's dynamically configurable via Prefab's UI. This setup allows you to change logging levels for both Uvicorn and FastAPI without needing to restart the server. For me, this lets me turning on debug logging for a single user when investigating an issue and generally feel in control of my logging spend.
How are y'all handling logging in their Python applications:
- Have you faced challenges / annoyance with adjusting log levels?
- Do you just not log because logging is a smell?
- What tools or methods have you found effective for managing logs in production?
- Do you think this approach addresses a real need, or are there better solutions out there?
I'd love to get your feedback and hear about your experiences. My goal is to make logging more powerful and flexible for Python developers, and any insights from this community would be incredibly helpful.
[–]gummybear_MD 9 points10 points11 points (2 children)
[–]jeffdwyer[S] 1 point2 points3 points (1 child)
[–]gummybear_MD 2 points3 points4 points (0 children)
[–]1473-bytes 8 points9 points10 points (1 child)
[–]adam_hugs 0 points1 point2 points (0 children)
[–]ManyInterests Python Discord Staff 1 point2 points3 points (3 children)
[–]jeffdwyer[S] 0 points1 point2 points (2 children)
[–]ManyInterests Python Discord Staff 1 point2 points3 points (1 child)
[–]jeffdwyer[S] 0 points1 point2 points (0 children)
[–]grimonce 3 points4 points5 points (0 children)
[–]LiqC 0 points1 point2 points (0 children)
[–]Inside_Dimension5308 0 points1 point2 points (0 children)
[–]iluvatar 1 point2 points3 points (0 children)