logging-best-practices

Define structured logging practices with wide events and middleware.

408|65|Updated Dec 12, 2024
One-click install
npx skills add https://github.com/deadlock-mod-manager/deadlock-mod-manager --skill logging-best-practices-deadlock-mod-manager
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: logging-best-practices
Source: https://github.com/deadlock-mod-manager/deadlock-mod-manager/tree/main/.agents/skills/logging-best-practices
Command: npx skills add https://github.com/deadlock-mod-manager/deadlock-mod-manager --skill logging-best-practices-deadlock-mod-manager

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill provides comprehensive guidelines for implementing robust and informative logging practices, helping developers produce high-quality, queryable logs that facilitate debugging and monitoring.

Core Features & Use Cases

  • Structured Wide Events: Guides on emitting a single, comprehensive log per request in JSON format.
  • Context Enrichment: Instructions on including high-cardinality, business, and environment data in logs.
  • Middleware Pattern: Implements middleware to automatically capture timing, status, and environment context.
  • Best Practices: Recommends using a single logger instance and consistent schemas across services.
  • Use Case: Apply this in production systems to standardize logs for better observability and faster issue resolution.

Quick Start

Configure your application to use the provided middleware and the shared logger to automatically generate structured logs for each request.

Frequently Asked Questions about logging-best-practices

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

FAQPage Schema
What is structured logging with wide events and when do I need it?

Structured logging with wide events emits a single, comprehensive JSON log per request containing high-cardinality, business, and environment data. You need it to improve debugging and operational insights across distributed systems.

How do I implement structured logging using middleware in my application?

Implement structured logging by configuring your application to use provided middleware and a shared logger instance. This middleware automatically captures timing, status, and environment context to generate uniform JSON logs for each request.

What's the best way to standardize logs across distributed services?

The best way to standardize logs across distributed services is using a single logger configuration with consistent schemas. This ensures uniform, queryable structured wide events that facilitate faster issue resolution.

Does structured logging require high-cardinality data to be effective?

Effective structured logging requires including high-cardinality, business, and environment data. This context-rich information transforms basic logs into wide events that significantly enhance observability and debugging capabilities.

Why should I use a single logger instance for application observability?

Using a single logger instance ensures log uniformity and consistent schemas across your application. This approach prevents fragmented logging configurations and maintains high-quality, queryable logs for better operational insights.