Structured Logging for the Standard Library
summary
Go 1.21 adds slog, a structured-logging API with two built-in handlers (text Handler and json Handler), integer levels with info at zero and a dynamic LevelVar, and a fast path called log.Add with Adder/slog.Value to avoid allocations. Groups and a LogValue method prevent key/type conflicts. Performance targets match Zap: benchmarks use parallel runs with roughly five attributes (common case), a fixed-size array to avoid allocations, and sync.Pool byte buffers; Handler has Enabled and preformat hooks for early rejection and caching.
AI-written summary · about








