golang-samber-slog

Implement structured logging in Golang with samber/slog handlers.

Updated May 30, 2026
One-click install
npx skills add https://github.com/ozan-fn/mqtt-capture --skill golang-samber-slog-ozan-fn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-samber-slog
Source: https://github.com/ozan-fn/mqtt-capture/tree/main/.agents/skills/golang-samber-slog
Command: npx skills add https://github.com/ozan-fn/mqtt-capture --skill golang-samber-slog-ozan-fn

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires slog-multi, slog-sampling, slog-formatter, slog-zap, slog-zerolog, slog-logrus, slog-datadog, slog-sentry, slog-loki, slog-graylog, slog-kafka, slog-fluentd, slog-logstash, slog-nats, slog-otel, slog-parquet, slog-quickwit, slog-rollbar, slog-mock, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill addresses the need for structured logging in Golang applications, offering a robust solution for logging, sampling, formatting, and routing.

Core Features & Use Cases

  • Structured Logging: Implement structured logging using the samber/slog libraries.
  • Comprehensive Handling: Utilize a variety of handlers for different log destinations, including cloud services, messaging systems, and storage.
  • Routing: Route logs based on severity, message content, or other attributes.
  • Use Case: For a Golang application, use this Skill to route ERROR logs to Sentry, WARN and INFO logs to Loki, and DEBUG logs to stdout.

Quick Start

To start logging, use the golang-samber-slog skill and set up your logger configuration as follows:

logger := slog.New(
    slogmulti.Pipe(
        samplingMiddleware,
        piiScrubbingMiddleware,
        traceInjectionMiddleware
    ).Handler(sinkHandler),
)

Frequently Asked Questions about golang-samber-slog

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

FAQPage Schema
How do I route structured logs to multiple destinations in Golang?

Route structured logs to multiple destinations in Golang by configuring handler pipelines that direct logs based on severity, message content, or attributes. This enables sending ERROR logs to Sentry and INFO logs to Loki simultaneously.

What is the best way to implement log sampling in a Go application?

Implement log sampling in a Go application by integrating a sampling middleware into your structured logging pipeline. This reduces log volume by selectively processing entries before they reach the configured sink handler.

Can I use samber slog with cloud services like Datadog and Sentry?

Yes, you can use samber slog with cloud services like Datadog and Sentry. The framework provides dedicated handlers for routing structured logs directly to various cloud monitoring platforms and storage solutions.

Does structured logging in Golang support PII scrubbing and trace injection?

Structured logging in Golang supports PII scrubbing and trace injection by chaining dedicated middleware components. You configure these middlewares in a pipe to sanitize sensitive data and inject tracing context before routing logs.

How do I migrate from logrus or zerolog to structured logging in Go?

Migrate from logrus or zerolog to structured logging in Go by utilizing dedicated slog handler adapters. These adapters route logs through the new structured pipeline while maintaining compatibility with your existing logging infrastructure.