Skip to content
secondsky avatar

Logging Best Practices

Structured logging guidance covering log levels, request context, PII redaction, and production logging rules.

CCM score
52 of 100
skills.sh installs
419
GitHub stars
257
last updated
Aug 21, 2026
View on GitHub

Own this skill? Claim it

What it does

  • Covers log level selection, from DEBUG through FATAL, with which levels stay on in production
  • Includes Winston JSON logger setup, AsyncLocalStorage request context, and a PII sanitizer for password, SSN, card, and token fields
  • Enforces rules such as no console.log in production, no logging inside tight loops, and no passwords or tokens in logs
  • Designed for Node.js services that need correlation IDs, with Python, Go, ELK, CloudWatch, and OpenTelemetry covered in a reference file

Install

$ npx -y skills add secondsky/claude-skills --skill logging-best-practices -y

Installs into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.

Files

Logging Best Practices

Implement secure, structured logging with proper levels and context.

Log Levels

LevelUse ForProduction
DEBUGDetailed debuggingOff
INFONormal operationsOn
WARNPotential issuesOn
ERRORErrors with recoveryOn
FATALCritical failuresOn

Structured Logging (Winston)

const winston = require('winston');

const logger = winston.createLogger({
  level: process.env.LOG_LEVEL || 'info',
  format: winston.format.combine(
    winston.format.timestamp(),
    winston.format.json()
  ),
  defaultMeta: { service: 'api-service' },
  transports: [
    new winston.transports.Console(),
    new winston.transports.File({ filename: 'error.log', level: 'error' })
  ]
});

// Usage
logger.info('User logged in', { userId: '123', ip: '192.168.1.1' });
logger.error('Payment failed', { error: err.message, orderId: '456' });

Request Context

const { AsyncLocalStorage } = require('async_hooks');
const storage = new AsyncLocalStorage();

Details

Repository
github.com/secondsky/claude-skills
Categories
Backend & APIs, DevOps & Cloud, Debugging
First seen
Jun 3, 2026

Questions

What does the logging-best-practices skill help with?

The logging-best-practices skill helps an agent implement structured logging with proper levels, request context, PII sanitization and centralized log aggregation. It also covers log bloat, PII exposure and missing context errors. The skill includes Winston examples and references for Python structlog, Go zap, ELK Stack, AWS CloudWatch and OpenTelemetry tracing.

How do I install the logging-best-practices skill?

Run npx -y skills add secondsky/claude-skills --skill logging-best-practices -y in your project. Once installed, the agent can apply the skill's guidance on log levels, correlation IDs and redaction of sensitive fields when you add logging to an application.

Which skills lead the Backend & APIs category that logging-best-practices belongs to?

In the Backend & APIs category, logging-best-practices sits alongside entra-app-registration, neon, firebase-basics, firebase-auth-basics and workers-best-practices. It focuses on application logging, log management integration and distributed tracing rather than database or authentication setup.

Does the logging-best-practices skill cover PII handling in logs?

Yes, the skill includes a PII sanitization pattern that redacts fields such as password, ssn, creditCard and token. It also partially masks email addresses before they are written to logs, and its guidance says to sanitize all PII before logging.

More from secondsky/claude-skills

All 116

Similar to Logging Best Practices

More Backend & APIs