logging-best-practices

Generate structured JSON wide event logs with business context.

Updated Jan 25, 2026
One-click install
npx skills add https://github.com/kunhai-88/skills --skill logging-best-practices-kunhai-88
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging-best-practices
Source: https://github.com/kunhai-88/skills/tree/main/logging-best-practices
Command: npx skills add https://github.com/kunhai-88/skills --skill logging-best-practices-kunhai-88

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the challenge of debugging and analyzing application behavior by promoting the use of structured, context-rich log events (wide events or canonical log lines). It helps move beyond scattered, low-context logs to a centralized, queryable data source.

Core Features & Use Cases

  • Wide Events: Emphasizes emitting a single, comprehensive log event per request/service, containing all relevant context.
  • Contextual Data: Guides on including high-cardinality and high-dimensionality data, business context, and environment features in logs.
  • Use Case: When a critical checkout failure occurs, this skill ensures logs contain user subscription level, cart value, and feature flag status, enabling rapid identification of the root cause and business impact.

Quick Start

Use the logging-best-practices skill to generate a structured, wide event log for the current request.

Frequently Asked Questions about logging-best-practices

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

FAQPage Schema
What are wide events in structured logging and when do I need them?

Wide events, or canonical log lines, are single comprehensive log events per request containing all relevant context. You need them when moving beyond scattered, low-context logs to a centralized, queryable data source for enhanced debugging and observability.

How do I implement canonical log lines for better application observability?

Implement canonical log lines by emitting a single, structured JSON log event per request. Include high-cardinality, high-dimensionality data, business context, and environment features to ensure logs capture comprehensive debugging information across services.

What context should I include in structured logs to debug critical failures?

Include high cardinality, high dimensionality data, business context, and environmental features in structured logs. For a critical checkout failure, capturing user subscription level, cart value, and feature flag status enables rapid identification of the root cause and business impact.

Does structured logging require middleware for consistent event generation across services?

Yes, utilizing middleware is recommended for consistent event generation across services. The approach also advises employing a single logger instance to standardize the JSON structured logs and maintain uniform observability data throughout the application.

What is the best way to structure application logs for debugging and analysis?

The best way to structure application logs is using JSON format to create wide events. This approach centralizes queryable data by combining high-cardinality dimensions, business context, and environmental features into a single comprehensive log event per request.

Why does scattered low-context logging fail during critical application debugging?

Scattered, low-context logging fails because it lacks the high cardinality and business context needed to trace application behavior. Without structured wide events, identifying the root cause and business impact of critical failures requires manual correlation across fragmented logs.