golang-samber-slog

Compose structured Go logging pipelines with samber/slog-multi middleware.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Developers need a unified way to configure structured logging in Go, handling sampling, PII scrubbing, HTTP request tracing, and routing to various backends without writing repetitive boilerplate.

Core Features & Use Cases

  • slog-multi composition: combine multiple handlers (Fanout, Router, Failover, Pool) in a single pipeline.
  • slog-sampling: apply rate‑limited or threshold sampling to reduce log volume.
  • slog-formatter: mask PII such as emails or IP addresses before logs leave the process.
  • HTTP middleware: ready‑made gin, echo, fiber, chi, and net/http integrations that inject request attributes.
  • Backend routing: send logs to Datadog, Sentry, Loki, Syslog, Logstash, Graylog, and other sinks with graceful shutdown support.
  • Use case: a microservice that records request traces, scrubs user data, samples high‑frequency debug logs, and forwards errors to Sentry while streaming all logs to Loki.

Quick Start

Create a logger that samples 10 % of info logs, scrubs email fields, routes errors to Sentry, and writes all records to stdout as JSON.

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 multiple backends?

Structured logging pipelines in Go can be configured using slog-multi to compose multiple handlers like Fanout, Router, and Failover, sending logs to various cloud backends without repetitive boilerplate.

What is the best way to reduce log volume in Go microservices?

Log volume in Go microservices is reduced by applying rate-limited or threshold sampling to high-frequency logs, dropping a configurable percentage of records before they reach the logging pipeline output.

How do I scrub PII such as emails and IP addresses from Go application logs?

Scrubbing PII from Go application logs is handled by slog-formatter middleware, which masks sensitive fields like emails and IP addresses before records leave the process to protect user data.

Can I route Go logs to Sentry, Loki, and Datadog at the same time?

Routing Go logs to Sentry, Loki, and Datadog simultaneously is supported by composing fanout handlers in a single pipeline, forwarding records to multiple sinks with graceful shutdown support.

Does this structured logging approach work with Go HTTP frameworks like Gin and Echo?

Yes, structured logging works with Go HTTP frameworks like Gin, Echo, Fiber, and Chi through ready-made middleware integrations that inject request attributes into the logging pipeline.

How do I set up a single Go logger that samples debug logs and routes errors separately?

A single Go logger that samples debug logs and routes errors separately is built by composing sampling middleware with a router handler, directing errors to Sentry while streaming all logs as JSON.