logging-best-practices

Implement structured JSON logging with correlation IDs and PII redaction.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

Centralizes guidance and implementation patterns to produce structured, secure, and performant application logs so teams can reliably debug, monitor, and comply with data policies without overwhelming storage or exposing sensitive data.

Core Features & Use Cases

  • Structured JSON logs with standardized fields and ISO 8601 timestamps for machine-readable indexing and search.
  • Contextual logging with request/correlation IDs and distributed tracing integration to connect logs across microservices.
  • PII sanitization, sampling strategies for high-volume services, and shipping to centralized systems like ELK or CloudWatch; example: instrument a user-service to redact emails, include requestId on all entries, and forward error-level logs to ELK.

Quick Start

Generate a JSON Winston logger configuration with ISO 8601 timestamps, correlation ID injection, PII redaction rules, and an ELK transport for error and combined logs.

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 and why do I need it for my microservices?

Structured logging formats application logs as JSON with standardized fields and ISO 8601 timestamps. It enables machine-readable indexing and centralized search, allowing teams to reliably debug and monitor distributed microservices.

How do I implement PII redaction in application logs?

PII redaction in application logs is implemented by applying sanitization rules to your logger configuration. This process removes sensitive data, like user emails, before forwarding error-level logs to centralized stores such as ELK or CloudWatch.

How do I add correlation IDs to logs for distributed tracing?

Correlation IDs are added to logs by injecting contextual fields like requestId into all log entries across microservices. This integrates with distributed tracing to connect logs, enabling end-to-end visibility during debugging.

What is the best way to handle high-volume log traffic in production?

The best way to handle high-volume log traffic is implementing log sampling strategies. Sampling controls the volume of logs generated by high-traffic services, preventing storage overload while retaining necessary debugging data.

Can I use this structured logging approach with Winston and ELK?

Yes, this structured logging approach works with Winston and ELK. You can generate a JSON Winston logger configuration featuring ISO 8601 timestamps, correlation ID injection, PII redaction, and an ELK transport for combined logs.

Does centralized logging support OpenTelemetry and CloudWatch?

Centralized logging supports both OpenTelemetry and CloudWatch. It standardizes log levels and formats contextual fields, allowing you to ship logs to CloudWatch or integrate with OpenTelemetry for production monitoring.