Resources for slog
This page links to projects that use or enhance slog
, the structured logging package for the standard library.
Log formatting
- slog-formatter: Common formatters for slog + helpers for building your own: samber/slog-formatter
- ConsoleHandler (similar to Zap's ConsoleEncoder): https://gist.github.com/wijayaerick/de3de10c47a79d5310968ba5ff101a19
- logf (attr {key} interpolation, rich tty output): https://pkg.go.dev/github.com/AndrewHarrisSPU/logf (uses lazy Handler stores: https://go.dev/play/p/psdD7KDF5fp )
- slogd - slog with duration kaihendry/slogd with video https://youtu.be/IsPa11N5pzI
- tinted (colorized) output: https://pkg.go.dev/github.com/lmittmann/tint
- humane: a human-friendly (but still largely structured) slog Handler: telemachus/humane
- slug: a handler that prints colourful logs for humans: dotse/slug
- slogor: A colorful slog handler: greyxor/slogor
- klog: the text format used by Kubernetes. Provides klog output routing when using the main package's logger and a simpler logger that just writes to stderr. Both slog/logr and go-logr/logr APIs are supported.
- slogjson: Format using the upcoming JSON v2 library, with optional single-line pretty-printing: veqryn/slog-json
Logger bridge
- Zap Handler, a slog handler that uses Zap: chanchal1987/zaphandler
- zapr: starting with v1.3.0, both slog/logr and go-logr/logr APIs are supported by the same logger instance.
Logging Middleware
- slogctx: store attributes or the logger in context, read any custom values from context: veqryn/slog-context
- slog-context/otel: automatically read and add OpenTelemetry TraceID and SpanID to logs, and can set Span error code: github.com/veqryn/slog-context/otel
- slogdedup: deduplication and sorting of attribute keys, with multiple policies, useful for json logging. Convenience methods to output for Stackdriver, Graylog, and others: veqryn/slog-dedup
HTTP server middleware
- slog-gin: Gin middleware for slog logger: samber/slog-gin
- slog-echo: Echo middleware for slog logger: samber/slog-echo
- slog-fiber: Fiber middleware for slog logger: samber/slog-fiber
- slog-chi: Chi middleware for slog logger: samber/slog-chi
Log sinks
- Experimental example using both OpenTelemetry and
slog
: justinsb/experiments-slog - Simple slog handler with opentelemetry tracing: https://github.com/ttys3/slogsimple/tree/main
- slog-datadog: a
slog.Handler
for Datadog: samber/slog-datadog - slog-rollbar: a
slog.Handler
for Rollbar: samber/slog-rollbar - slog-sentry: a
slog.Handler
for Sentry: samber/slog-sentry - slog-syslog: a
slog.Handler
for Syslog: samber/slog-syslog - slog-logstash: a
slog.Handler
for Logstash: samber/slog-logstash - slog-fluentd: a
slog.Handler
for Fluentd: samber/slog-fluentd - slog-graylog: a
slog.Handler
for Graylog: samber/slog-graylog - slog-loki: a
slog.Handler
for Loki: samber/slog-loki - slog-slack: a
slog.Handler
for Slack: samber/slog-slack - slog-telegram: a
slog.Handler
for Telegram: samber/slog-telegram - slog-mattermost: a
slog.Handler
for Mattermost: samber/slog-mattermost - slog-microsoft-teams: a
slog.Handler
for Microsoft Teams: samber/slog-microsoft-teams - slog-webhook: a
slog.Handler
for Webhook: samber/slog-webhook - slog-kafka: a
slog.Handler
for Kafka: samber/slog-kafka - slogbugsnag: a
slog.Handler
for Bugsnag: veqryn/slog-bugsnag - slogdriver: a
slog.Handler
for Stackdriver Logging / GCP Cloud Logging: jussi-kalliokoski/slogdriver
Handlers
- slog-multi: chain of
slog.Handler
(pipeline, fanout, …): samber/slog-multi - various handlers: galecore/xslog
Other:
- Additional resources written by jba: jba/slog
- slog-sampling: drop repetitive log entries: samber/slog-sampling
- slog-context: adds support to reading values from context: PumpkinSeed/slog-context
- slogassert: handle for testing slog logs emitted by code: thejerf/slogassert
- sloggen: generate various helpers for
log/slog
: go-simpler/sloggen - sloglint: ensure consistent code style when using
log/slog
: go-simpler/sloglint