Slog: The Future Face of Go Logging?

<p>Go 1.21 introduced structured logging to the standard library. A much-anticipated feature is now available within the familiar&nbsp;<code>log</code>&nbsp;package under the aptly named&nbsp;<code><a href="https://pkg.go.dev/log/slog" rel="noopener ugc nofollow" target="_blank">slog</a></code>&nbsp;sub-package. This advancement employs key-value pairs to enable rapid parsing, filtering, and analysis of logs, addressing the crucial need for efficient debugging.</p> <blockquote> <p><strong>D.O.:</strong>&nbsp;I have previously mentioned Slog when discussing error handling in the Go Excellence series. If you missed it, you can read it&nbsp;<a href="https://itnext.io/go-excellence-a-deep-dive-into-error-handling-4b74697f12a1" rel="noopener ugc nofollow" target="_blank">here</a>.</p> </blockquote> <p>It sounds very exciting and certainly holds promise, but it&rsquo;s also vital to acknowledge certain realities.</p> <p>The fact is that Slog is late. Around ten years has passed since one of the first structured loggers were developed in Go. I am referring to&nbsp;<code><a href="https://pkg.go.dev/github.com/sirupsen/[email protected]" rel="noopener ugc nofollow" target="_blank">logrus</a></code>, a veteran with a decade of experience, which has garnered substantial popularity, boasting an impressive 23.2K stars on GitHub and over&nbsp;<a href="https://pkg.go.dev/github.com/sirupsen/logrus?tab=importedby" rel="noopener ugc nofollow" target="_blank">135,627</a>&nbsp;imports and still growing.</p> <p><a href="https://itnext.io/slog-the-future-face-of-go-logging-d82ee9073a04">Visit Now</a></p>