go-logging

Convert Go application logging to structured slog records with request-scoped fields.

8|Updated Jun 5, 2026
One-click install
npx skills add https://github.com/muratmirgun/gophers --skill go-logging-muratmirgun
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-logging
Source: https://github.com/muratmirgun/gophers/tree/main/skills/go-logging
Command: npx skills add https://github.com/muratmirgun/gophers --skill go-logging-muratmirgun

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you write production-grade Go logging that is structured, consistent, and useful at 3 a.m. when someone needs to diagnose a live incident. It prevents noisy, duplicate, or unsafe logs by steering code toward the standard library logger and away from ad hoc printf-style output.

Core Features & Use Cases

  • Structured logging with slog: Choose log/slog for new Go services, emit static messages with typed fields, and keep logs easy to index and search.
  • Request-scoped context: Attach request IDs and other per-request fields once in middleware, then inherit them through downstream calls.
  • Level and handler guidance: Decide between debug, info, warn, and error correctly, add redaction or sampling in handlers, and migrate from zap, logrus, or zerolog when needed.
  • Use case: A Go API receives a checkout request, derives a request logger in middleware, records an error once at the request boundary, and returns a sanitized response while keeping operator logs rich and consistent.

Quick Start

Ask the skill to convert your Go code to structured slog logging with request-scoped fields, correct levels, and safe redaction.

Frequently Asked Questions about go-logging

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

FAQPage Schema
How do I replace unstructured Go logging with slog structured records?

Replace unstructured printf-style output with slog-based, field-rich records by emitting static messages with typed fields. This ensures Go application logging is structured, consistent, and easy to index for production incident diagnosis.

How do I pass request-scoped context fields through downstream Go calls?

Attach request IDs and per-request fields once in middleware, then inherit them through downstream calls using request-scoped context propagation. This maintains consistent log entries across the entire HTTP request handling workflow.

What is the best way to migrate from zap or logrus to standard library slog?

Migrate from zap, logrus, or zerolog to slog by selecting correct log levels, applying handler-based redaction, and eliminating duplicate log-and-return behavior. This aligns Go services with the standard library logger for production-grade output.

How do I add redaction to Go structured logs without duplicating log entries?

Add redaction or sampling directly in handlers to sanitize sensitive fields, and ensure errors are recorded once at the request boundary. This prevents noisy, duplicate, or unsafe logs while keeping operator records rich and consistent.

Does slog work for background jobs and service startup logging in Go?

slog works for service startup, HTTP request handling, background jobs, and error reporting workflows. It requires correct level selection between debug, info, warn, and error to produce production-grade, structured Go application logs.