Go 1.21 introduced structured logging to the standard library. A much-anticipated feature is now available within the familiar log package under the aptly named slog sub-package. This advancement employs key-value pairs to enable rapid parsing, filtering, and analysis of logs, addressing the crucial need for efficient debugging.
D.O.: I have previously mentioned Slog when discussing error handling in the Go Excellence series. If you missed it, you can read it here.
It sounds very exciting and certainly holds promise, but it’s also vital to acknowledge certain realities.
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 logrus, a veteran with a decade of experience, which has garnered substantial popularity, boasting an impressive 23.2K stars on GitHub and over 135,627 imports and still growing.