<p>Go 1.21 introduced structured logging to the standard library. A much-anticipated feature is now available within the familiar <code>log</code> package under the aptly named <code><a href="https://pkg.go.dev/log/slog" rel="noopener ugc nofollow" target="_blank">slog</a></code> 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> I have previously mentioned Slog when discussing error handling in the Go Excellence series. If you missed it, you can read it <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’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 <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 <a href="https://pkg.go.dev/github.com/sirupsen/logrus?tab=importedby" rel="noopener ugc nofollow" target="_blank">135,627</a> imports and still growing.</p>
<p><a href="https://itnext.io/slog-the-future-face-of-go-logging-d82ee9073a04">Visit Now</a></p>