logging-best-practices

Implements wide-event structured logging patterns for request-level observability and debugging.

Updated Apr 30, 2026
One-click install
npx skills add https://github.com/AdityaBorkar/igbot-fork --skill logging-best-practices-adityaborkar
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: logging-best-practices
Source: https://github.com/AdityaBorkar/igbot-fork/tree/main/.agents/skills/logging-best-practices
Command: npx skills add https://github.com/AdityaBorkar/igbot-fork --skill logging-best-practices-adityaborkar

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Scattered console.log statements and unstructured log lines make production debugging painful because you cannot query logs by user, request, or business context. This Skill guides you to emit one context-rich wide event per request per service, turning logs into queryable data. ## Core Features & Use Cases - Wide Event Pattern: Consolidate all request context into a single structured JSON event emitted in a finally block, covering timing, status, errors, and business data. - Context & Cardinality Rules: Enforce high-cardinality fields (user IDs, request IDs), business context (subscription tier, cart value), and environment metadata (commit hash, region, version) in every event. - Structure & Anti-Pattern Guidance: Standardize on a single logger, middleware-based event collection, JSON format, consistent schemas, and two log levels while avoiding scattered logs and missing request correlation. - Use Case: When a premium customer reports a failed checkout, query your logs by request_id and instantly see the full event: user subscription, cart total, feature flags, error type, and the exact commit hash deployed. ## Quick Start Ask the AI to review your request handler's logging and refactor it to emit a single wide event with user, business, and environment context.

Frequently Asked Questions about logging-best-practices

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

FAQPage Schema
How do I implement wide events in a request handler?▼

Initialize a wide event object at request start, enrich it with user, cart, and business context as the handler executes, then emit it once in a finally block with duration_ms and status_code. Use middleware to handle timing, environment fields, and emission so handlers only add business context.

What is a canonical log line in structured logging?▼

A canonical log line is one context-rich event emitted per request per service instead of many scattered log lines. Popularized by Stripe, it combines timing, status, user, and business data into a single JSON object that is fully queryable.

How do I correlate logs across multiple services?▼

Propagate a unique request ID through HTTP headers like x-request-id on every service hop and include it in each wide event. Querying by that request_id then reconstructs the full request journey across services.

Should I use multiple log levels like debug, warn, and trace?▼

No, this approach simplifies to just two levels: info for normal operations and error for unexpected failures. Instead of debug logs, add the extra context as fields on your wide event so it stays queryable.

Why is console.log bad for production debugging?▼

Unstructured console.log strings cannot be queried by field, so you cannot filter by user, subscription tier, or request ID. Structured JSON wide events let you answer unanticipated questions without redeploying code.