logging-best-practices

Consolidate request-scoped logging into single structured JSON events.

Updated Apr 8, 2026
One-click install
npx skills add https://github.com/tonomb/personal-pnl --skill logging-best-practices-tonomb
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging-best-practices
Source: https://github.com/tonomb/personal-pnl/tree/main/.agents/skills/logging-best-practices
Command: npx skills add https://github.com/tonomb/personal-pnl --skill logging-best-practices-tonomb

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill addresses the chaos of scattered, unstructured log lines that make debugging distributed systems nearly impossible by providing a standardized, context-rich logging pattern.

Core Features & Use Cases

  • Wide Events Pattern: Consolidates request data into a single, high-cardinality event emitted at the end of a request.
  • Context Enrichment: Ensures business and environment metadata are automatically included for every log entry.
  • Use Case: When a high-value customer experiences a checkout failure, this skill ensures you have the exact user ID, cart value, and deployment version in one queryable log entry rather than searching through dozens of unrelated lines.

Quick Start

Apply the logging best practices skill to refactor the current request handler to use a single wide event emitted 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 the wide events pattern for structured logging?

The wide events pattern consolidates scattered, unstructured log lines into a single, context-rich structured JSON event emitted at the end of a request. It includes high-cardinality business and environment metadata to improve distributed system debugging.

How do I debug distributed systems using structured logging?

You can debug distributed systems by implementing structured logging with wide events. This ensures business metadata, request IDs, and environment context are automatically enriched in a single queryable log entry per request.

How do I consolidate request-scoped logging into a single event?

You can consolidate request-scoped logging by applying middleware to capture request data and emitting a single wide event in a finally block. This ensures consistent JSON formatting and automatic context enrichment for the entire request lifecycle.

What's the best way to capture business context in backend service logs?

The best way to capture business context is using wide events with structured logging. This automatically includes metadata like user IDs and cart values in a single high-cardinality event, preventing the need to search through dozens of unrelated log lines.

Does middleware-based log emission work with request ID propagation?

Yes, middleware-based log emission works seamlessly with request ID propagation. The wide events pattern relies on middleware to automatically enrich logs with propagated request IDs and consistent JSON formatting across backend services.

When do I need wide events for observability?

You need wide events for observability when high-value transactions fail and you require exact business metadata in one queryable entry. This pattern solves the chaos of scattered logs by consolidating context-rich data into a single structured event.