MENU

Fun & Interesting

JSON logs in Python apps - with FastAPI & python-json-logger!

Better Stack 4,375 1 year ago
Video Not Working? Fix It Now

In this video, we'll look at how to output logs in JSON format from Python applications. We will demonstrate this with the "python-json-logger" package, and will also show how to centralize our logs by sending them to Better Stack from our application code. ► RELATED GUIDES 10 Best Practices for Logging in Python: https://betterstack.com/community/guides/logging/python/python-logging-best-practices/ Logging in Python: A Comparison of the Top 6 Libraries: https://betterstack.com/community/guides/logging/best-python-logging-libraries/ How to Get Started with Logging in Django: https://betterstack.com/community/guides/logging/how-to-start-logging-with-django/ ► HACKING SCALE NEWSLETTER https://newsletter.betterstack.com/ ► READ MORE More about Better Stack: https://betterstack.com/ Community pages: https://betterstack.com/community/ ► STAY TUNED GitHub: https://github.com/BetterStackHQ Twitter: https://twitter.com/betterstackhq LinkedIn: https://www.linkedin.com/company/betterstack Instagram: https://www.instagram.com/betterstackhq/ TikTok: https://www.tiktok.com/@betterstack 📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀: 00:00 Intro 00:47 python-json-logger intro 01:16 Starter Project 02:39 Creating python environment 03:49 Creating FastAPI handler 09:27 Outputting logs in JSON format with python-json-logger 11:29 Sending Python logs to Better Stack 15:44 Creating FastAPI handler with a path parameter #logging #python #pythonprogramming

Comment