logging-best-practices

Configure middleware to emit JSON wide events with environment and business context.

3|Updated Jan 6, 2026
One-click install
npx skills add https://github.com/trancong12102/ccc --skill logging-best-practices-trancong12102
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging-best-practices
Source: https://github.com/trancong12102/ccc/tree/main/external/skills/logging-best-practices
Command: npx skills add https://github.com/trancong12102/ccc --skill logging-best-practices-trancong12102

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill enables consistent, context-rich wide-event logging across distributed services to improve observability and incident analysis.

Core Features & Use Cases

  • Wide events: Emit a single, context-rich event per request per service for reliable traceability.
  • High cardinality & dimensionality: Include user, request, and environment data to support deep queries.
  • Middleware-driven structure: Use a reusable middleware pattern to collect timing, status, and environment context.
  • JSON-based schema: Maintain a consistent, queryable log format across services.
  • Real-world use: Debug cross-service transactions and perform post-mortem analysis with rich context.

Quick Start

Configure a middleware to emit a single JSON wide event per request and enrich it with business context.

Frequently Asked Questions about logging-best-practices

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

FAQPage Schema
What are canonical log lines for distributed service debugging?

Canonical log lines are single, context-rich wide events emitted per request per service. They improve observability by embedding user, request, and environment data for reliable end-to-end traceability and post-mortem analysis.

How do I implement middleware-based JSON logging for backend APIs?

Implement middleware-based JSON logging by configuring a single logger to collect timing, status, and environment context. This middleware emits one wide event per request, enriching it with business context for queryable analytics.

Why use wide events instead of traditional multiple log entries per request?

Wide events provide high cardinality and dimensionality by including user, request, and environment data in a single output. This approach prevents fragmented logs, supporting deep queries and reliable cross-service transaction debugging.

Does this logging approach work for microservices requiring end-to-end traceability?

Yes, this approach works for microservices by enforcing a consistent JSON schema across distributed services. Middleware-driven wide event collection ensures every request carries business and environment context for full traceability.

What is the best way to standardize log formats across multiple backend services?

The best way to standardize logs is using a single logger with a JSON-based schema. Applying a reusable middleware pattern ensures consistent wide event collection, maintaining queryable formats across all services.

How to include business context in API request logs for post-mortem analysis?

Include business context by configuring middleware to enrich each JSON wide event with user, request, and environment data. This high-dimensional logging approach captures the necessary details for deep post-mortem analysis.