Structured logging with slog

The new log/slog package in Go 1.21 brings structured logging to the standard library. Structured logs use key-value pairs for easy parsing, filtering, searching, and analysis. Structured logging has consistently ranked high in the annual survey of Go programmers and many popular Go packages already provide it. By including structured logging in the standard library, a common framework is provided for all structured logging packages to share. The slog package in Go 1.21 offers simple syntax for logging at different levels and allows for customization of log output format. Performance optimizations were implemented, and the slog package went through a thorough design process with community feedback. The package documentation and additional resources are available for learning more about slog.

https://go.dev/blog/slog

To top