logging-best-practices

Emit one context-rich JSON log per request per service.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/stamatim/agent-skills --skill logging-best-practices-stamatim
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: logging-best-practices
Source: https://github.com/stamatim/agent-skills/tree/main/.agents/skills/logging-best-practices
Command: npx skills add https://github.com/stamatim/agent-skills --skill logging-best-practices-stamatim

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Logging consistency and observability in distributed systems by enforcing the wide events canonical log lines pattern that captures rich context in a single end-of-request event.

Core Features & Use Cases

  • Wide Events: Emit one structured event per request per service, with complete context.
  • Context & Environment: Include high-cardinality fields, business context, and environment metadata in every event.
  • Middleware & Structure: Use a single logger and middleware to automatically generate and emit wide events in JSON format.
  • Guidance & Anti-Patterns: Provide guidelines and anti-patterns to avoid noisy, unstructured logging.

Quick Start

Adopt the middleware-based wide-event pattern in your services to start emitting a single, context-rich JSON log per request.

Frequently Asked Questions about logging-best-practices

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

FAQPage Schema
What are canonical log lines and how do they improve microservices observability?▼

Wide events, or canonical log lines, improve observability by emitting a single, context-rich JSON log per request per service, capturing complete business and environment context to simplify debugging.

How do I implement structured logging for APIs and background tasks?▼

Implement structured logging by using a single startup logger with middleware to automatically generate and emit wide events in a unified JSON format, ensuring request correlation across APIs and background tasks.

Does middleware-based wide event logging work for distributed systems?▼

Yes, middleware-based wide event logging works for distributed systems by automatically emitting one structured JSON event per request per service, including high-cardinality fields and business context for improved debuggability.

What is the best way to capture business context in microservices logs?▼

The best way to capture business context in microservices logs is adopting the wide events pattern, which uses middleware to bundle high-cardinality fields and environment metadata into a single end-of-request JSON event.

What are common anti-patterns when implementing structured logging?▼

Common structured logging anti-patterns include creating noisy, unstructured logs and scattering context across multiple lines, which this Skill avoids by enforcing a single, context-rich JSON wide event per request.