logging-best-practices

Installation
Summary

Structured logging pattern using wide events for comprehensive request-level debugging and analytics.

  • Consolidates all request context into a single JSON event per service, emitted at completion, rather than scattering log lines throughout handlers
  • Emphasizes high cardinality fields (user IDs, request IDs) and high dimensionality (many fields per event) to enable flexible querying and correlation across services
  • Requires business context in every event: subscription tier, cart value, feature flags, account age, plus environment metadata like commit hash, version, and region
  • Recommends middleware pattern for infrastructure concerns (timing, status, environment) while keeping handlers focused on business logic
SKILL.md

Logging Best Practices Skill

Version: 1.0.0

Purpose

This skill provides guidelines for implementing effective logging in applications. It focuses on wide events (also called canonical log lines) - a pattern where you emit a single, context-rich event per request per service, enabling powerful debugging and analytics.

When to Apply

Apply these guidelines when:

  • Writing or reviewing logging code
  • Adding console.log, logger.info, or similar
  • Designing logging strategy for new services
  • Setting up logging infrastructure

Core Principles

1. Wide Events (CRITICAL)

Installs
3.1K
GitHub Stars
85
First Seen
Jan 21, 2026