golang-samber-slog

Compose Go logging pipelines with samber/slog middleware, sampling, and formatting.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/nrmnqdds/gomaluum --skill golang-samber-slog-nrmnqdds
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-slog
Source: https://github.com/nrmnqdds/gomaluum/tree/main/.agents/skills/golang-samber-slog
Command: npx skills add https://github.com/nrmnqdds/gomaluum --skill golang-samber-slog-nrmnqdds

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Structured logging in Go often requires stitching together multiple libraries to build pipelines that sample, format, route, and ship logs to backends. This skill provides a coherent approach using samber/slog-multi, slog-sampling, and slog-formatter to compose robust logging pipelines.

Core Features & Use Cases

  • Compose modular logging pipelines using slog-multi for routing and fanout patterns.
  • Apply throughput control via slog-sampling to reduce noise while preserving critical logs.
  • Transform attributes with slog-formatter to scrub or shape data before sinks.
  • Integrate HTTP middlewares (slog-gin, slog-chi, slog-echo, slog-http) for request-scoped attributes.
  • Ship logs to backends like Loki, Sentry, Datadog using versioned slog backends.

Quick Start

Create a minimal Go logger using samber/slog that pipes a sampling middleware, a formatter, and a Router to send errors to Sentry and infos to Loki.

Frequently Asked Questions about golang-samber-slog

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a structured logging pipeline in Go that routes errors to Sentry and infos to Loki?

You can build a structured Go logging pipeline using slog-multi to route logs, sending errors to Sentry and infos to Loki through a modular Router that handles backend fanout and graceful shutdown.

How does slog-sampling control log throughput in high-traffic Go applications?

slog-sampling applies throughput control to your Go logging pipeline to reduce noise by sampling logs, preserving critical entries while dropping redundant ones during high-volume bursts.

Can I scrub PII from Go structured logs before sending them to backends like Datadog?

Yes, you can use slog-formatter to transform and scrub PII attributes, shaping log data before it reaches backend sinks like Datadog within your composed Go logging pipeline.

Does this Go logging approach work with HTTP middlewares like chi or echo?

Yes, the pipeline integrates HTTP middlewares such as slog-chi, slog-echo, slog-gin, and slog-http to inject request-scoped attributes into your structured Go logs.

What is the best way to combine multiple slog handlers for fanout logging in Go?

slog-multi provides middleware to compose modular Go logging pipelines, enabling fanout patterns where logs are routed and distributed to multiple handlers simultaneously.

How do I configure graceful shutdown for Go log sinks when using samber/slog?

The Option pattern configures backend sinks with graceful shutdown, ensuring buffered Go log entries are flushed to destinations like Loki or Sentry before the application terminates.