logging-best-practices

Emit one context-rich JSON wide event per request via middleware.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Logging best practices focused on wide events (canonical log lines) enable powerful debugging and analytics by collecting rich, context-laden data in a single, per-request event.

Core Features & Use Cases

  • Wide Events: Emit one context-rich event per request per service to simplify querying.
  • High Cardinality & Dimensionality: Include user IDs, request IDs, and many contextual fields for flexible analyses.
  • Business & Environment Context: Attach business data (subscriptions, cart value) and environment details (version, region) to every event.
  • Single Logger & Middleware: Use a single logger instance and a middleware pattern to ensure consistent formatting and emission lifecycle.
  • Structure & Consistency: Enforce JSON format and a shared schema across services.

Quick Start

Use a middleware to initialize a single wide event at request start, enrich it with business and environment context, and emit it in a finally block.

Frequently Asked Questions about logging-best-practices

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

FAQPage Schema
What is structured wide-event logging and why use it for debugging?

Structured wide-event logging emits a single, context-rich JSON event per request to simplify cross-service querying. It solves debugging complexity by consolidating business, environment, and timing data into one canonical log line for fast insights.

How do I implement wide-event logging using middleware?

To implement wide-event logging, use middleware to initialize a single globally shared logger at request start, enrich it with business and environment context, and emit the JSON event in a finally block to ensure consistent lifecycle management.

How do I propagate request IDs across services for observability?

Propagate request IDs across services by enforcing a consistent JSON schema and passing the request ID through middleware. This ensures every wide event carries the shared identifier, enabling accurate cross-service tracing and observability.

What context should I include in canonical log lines for analytics?

Canonical log lines should include high cardinality and high dimensionality context like user IDs, request IDs, business data such as cart value, and environment details like version and region to enable flexible, fast analyses.

Does structured logging require a single shared logger instance per service?

Yes, structured wide-event logging requires a single globally shared logger instance per service. This ensures consistent JSON formatting and schema enforcement across all middleware-enriched events emitted by the application.