logging-best-practices

Configure middleware to emit standardized JSON wide events per request for unified logging across services.

Updated Nov 15, 2025
One-click install
npx skills add https://github.com/geinala/entry --skill logging-best-practices-geinala
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging-best-practices
Source: https://github.com/geinala/entry/tree/main/.agents/skills/logging-best-practices
Command: npx skills add https://github.com/geinala/entry --skill logging-best-practices-geinala

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Logging discipline and wide-event patterns to enable unified, queryable, context-rich logs across services.

Core Features & Use Cases

  • Wide-events: emit a single, complete log per request per service to minimize noise and maximize observability.
  • High cardinality and dimensionality: capture business and environment context to support unknown-unknown debugging.
  • Middleware-based consistency: use a shared logger and middleware to auto-collect environment data and timing.
  • Use case: standardize logging for distributed APIs to simplify tracing across service hops.

Quick Start

Configure a global, single logger and middleware to emit one JSON wide event 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 wide events in structured logging and how do they work?

Wide events in structured logging emit a single, complete JSON log per request per service to minimize noise and maximize observability. This approach captures comprehensive business and environment context to support unknown-unknown debugging.

How do I standardize structured logging across distributed APIs for tracing?

To standardize structured logging across distributed APIs, configure a single shared logger and middleware to automatically emit one JSON wide event per request. This ensures consistent context collection and simplifies tracing across service hops.

What's the best way to capture high cardinality and dimensionality in logs?

The best way to capture high cardinality and dimensionality in logs is by using middleware to auto-collect environment data and timing. This enforces standardized wide events that include business and environment context for deep observability.

Do I need middleware to implement canonical log lines for observability?

Yes, you need middleware to implement canonical log lines effectively. Middleware integrates with a shared logger to automatically collect environment and request context, ensuring a single queryable log per request for unified observability.

When should I not use a single wide event per request for logging?

You should not use a single wide event per request when your services generate exceptionally high request volumes or when logging complex asynchronous background jobs, as this approach is designed specifically for request-bound endpoints to simplify tracing.