MENU

Fun & Interesting

Go Structured Logging with the slog Package (Golang)

Better Stack 9,575 1 year ago
Video Not Working? Fix It Now

In this video, we take a look at the 'slog' package in Go - a recent addition to the standard library that allows for structured logging and better built-in logging capabilities! ► RELATED GUIDES Logging in Go: A Comparison of the Top 9 Libraries https://betterstack.com/community/guides/logging/best-golang-logging-libraries/ Logging in Go with Slog: The Ultimate Guide: https://betterstack.com/community/guides/logging/logging-in-go/ A Complete Guide to Logging in Go with Zerolog: https://betterstack.com/community/guides/logging/zerolog/ A Comprehensive Guide to Zap Logging in Go: https://betterstack.com/community/guides/logging/go/zap/ ► 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 05:15 slog package in Go 09:43 Setting default log level 11:26 Logging custom data to the output 16:00 Groups with slog.Group 19:56 Child loggers for consolidating attributes 24:23 Logging to Files 29:05 Logging to multiple destinations with io.MultiWriter 30:31 Redacting data by implementing LogValuer interface #golangtutorial #golang #logging

Comment