golang-samber-slog

Configure Go logging pipelines with samber/slog libraries for structured output.

2.9k|191|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/samber/cc-skills-golang --skill golang-samber-slog
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-samber-slog
Source: https://github.com/samber/cc-skills-golang/tree/main/skills/golang-samber-slog
Command: npx skills add https://github.com/samber/cc-skills-golang --skill golang-samber-slog

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Go projects often struggle with high-volume, structured logging that is easy to route, filter, and back-end efficiently. This skill shows how to compose pipelines using samber/slog libraries to achieve deterministic performance and clear log structures.

Core Features & Use Cases

  • 20+ composable slog.Handler packages for Go 1.21+ that enable pipeline construction, routing, and sinks.
  • Deterministic pipeline ordering (sampling outermost, then formatting, then routing) to minimize wasted CPU and ensure sinks see clean data.
  • HTTP middlewares and backends integration with versioned modules (e.g. slog-datadog, slog-loki, slog-sentry) for production-grade deployments.
  • Practical guidance for using Router vs Fanout, first-match vs multi-predicate routing, and graceful shutdown for batched sinks.

Quick Start

Configure a pipeline that samples noisy logs, formats attributes to remove sensitive data, and routes errors to Sentry while streaming normal logs 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 configure structured logging pipelines in Go for high-throughput services?▼

Configure structured logging pipelines in Go using samber/slog libraries to produce scalable, policy-compliant logs. It demonstrates proper pipeline ordering with sampling outermost, correct use of Router vs Fanout, and graceful shutdown of batched sinks using Option{}.NewXxxHandler constructors.

What's the best way to route Go slog logs to multiple backends like Sentry and Loki?▼

Route Go slog logs to multiple backends like Sentry and Loki using the Router and Fanout components. Router handles first-match routing for specific conditions, while Fanout supports multi-predicate routing to send logs to multiple destinations simultaneously.

How do I add log sampling and filtering middleware in Go slog pipelines?▼

Add log sampling and filtering middleware in Go slog by composing 20+ slog.Handler packages. Ensure deterministic pipeline ordering by placing sampling outermost, then formatting, then routing to minimize wasted CPU and ensure sinks see clean data.

Does the samber/slog pipeline support graceful shutdown for batched log sinks?▼

Yes, samber/slog pipelines support graceful shutdown for batched log sinks. The Skill demonstrates using the Option{}.NewXxxHandler constructors to properly configure and flush batched sinks during service shutdown.

When do I use Router vs Fanout for structured logging in Go services?▼

Use Router for first-match routing when you need logs to go to a single destination based on predicates. Use Fanout for multi-predicate routing when logs must be sent to multiple destinations simultaneously across your structured logging pipeline.

Can I integrate HTTP middleware with Go slog pipelines for production logging?▼

Yes, you can integrate HTTP middleware with Go slog pipelines. The Skill provides HTTP middlewares and backend integration with versioned modules like slog-datadog, slog-loki, and slog-sentry for production-grade deployments.