logging-config

Configure structured JSON logging with slog in Go projects.

2|Updated Feb 6, 2026
One-click install
npx skills add https://github.com/air-gapped/cooked --skill logging-config
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging-config
Source: https://github.com/air-gapped/cooked/tree/main/.claude/skills/logging-config
Command: npx skills add https://github.com/air-gapped/cooked --skill logging-config

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill standardizes logging across Go applications by enforcing the use of slog with structured fields, replacing ad-hoc logging patterns like fmt.Printf or log.Printf to produce consistent, machine-readable logs.

Core Features & Use Cases

  • Enforces use of slog and JSON-formatted output for all logs.
  • Provides a single, centralized logger initialization pattern to ensure consistent fields.
  • Improves observability and debugging by using structured key-value pairs.

Quick Start

  1. Initialize a global slog logger at program startup with a JSON handler that writes to stdout.
  2. Replace log.Printf/fmt.Println usages with slog using structured fields (e.g., slog.Info("request processed", "method", "GET", "path", "/login")).

Frequently Asked Questions about logging-config

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

FAQPage Schema
How do I set up structured logging in Go using slog?

To set up structured logging in Go using slog, initialize a global JSON logger at program startup that writes to stdout. Replace ad-hoc patterns like log.Printf with slog methods using structured key-value fields for machine-readable output.

Why should I use slog instead of log.Printf for observability in Go?

You should use slog instead of log.Printf because slog enforces structured, machine-readable JSON logging with consistent key-value pairs. This standardization significantly improves observability and simplifies debugging across Go services compared to unstructured text output.

What is the best way to standardize logs across multiple Go services?

The best way to standardize logs across multiple Go services is to enforce a single, centralized slog logger initialization pattern at startup. This ensures all services emit consistent, JSON-formatted structured fields for monitoring and debugging.

Can I configure a centralized slog logger for consistent fields in Go?

Yes, you can configure a centralized slog logger at program startup using a JSON handler. This single initialization pattern ensures that all subsequent logs emit with consistent, structured key-value fields instead of variable ad-hoc text.

How do I replace fmt.Println with structured fields in Go?

To replace fmt.Println with structured fields in Go, initialize a slog JSON handler at startup and call slog methods like slog.Info with key-value pairs, such as slog.Info("request processed", "method", "GET"), to produce machine-readable logs.

When do I need JSON formatted logs in Go applications?

You need JSON formatted logs in Go applications when services require consistent, machine-readable output for monitoring and debugging. Structured slog logging replaces unstructured text to improve observability and enable automated log analysis.