What problem does it solve?
It helps Go teams design reliable structured logging pipelines so every log record is sampled, sanitized, routed, and delivered to the right backend with consistent slog.Handler behavior.
Core Features & Use Cases
- Sampling-first noise reduction: apply slog-sampling as the outermost stage to drop low-value records early and avoid wasted CPU.
- PII-safe attribute formatting: use slog-formatter middleware to transform attributes (for example, masking PII fields and formatting errors) before they reach sinks.
- Multi-destination routing: compose handlers with slog-multi (Router, FirstMatch, Fanout, Pool, Failover, Pipe) to send the right events to the right systems (for example, route errors to Sentry and everything else to Loki).
- HTTP request logging integration: add request-aware context through samber/slog HTTP middlewares (slog-gin, slog-chi, slog-fiber, slog-echo, slog-http) and optionally propagate fields via backend AttrFromContext.
Quick Start
Configure a Go slog logger using a sampling middleware (from slog-sampling) plus a PII formatter middleware (from slog-formatter) and route ERROR-level logs to Sentry while routing non-errors to Loki using slog-multi Router.