Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
secondsky avatar

Logging Best Practices

  • 295 installs
  • 202 repo stars
  • Updated August 4, 2026
  • secondsky/claude-skills

logging-best-practices is a secondsky/claude-skills module that guides structured application logging patterns so developers can debug production services with consistent levels, context fields, and correlation identifie

About

logging-best-practices is an entry in secondsky/claude-skills aimed at application logging quality, though its catalog description is a stub and the readme excerpt is empty. From the skill name and repository theme, it helps agents apply structured logging conventions—appropriate log levels, contextual metadata, correlation IDs, and noise reduction—for services under real traffic. Backend and platform engineers reach for logging-best-practices when logs are unusable during incidents or when new services need a consistent logging contract across microservices. Validate recommendations against your existing log aggregator schema because the published skill body is minimal.

  • logging-best-practices

Logging Best Practices by the numbers

  • 295 all-time installs (skills.sh)
  • +10 installs in the week ending Jul 27, 2026 (Skillselion tracking)
  • Ranked #1,349 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/secondsky/claude-skills --skill logging-best-practices

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs295
repo stars202
Last updatedAugust 4, 2026
Repositorysecondsky/claude-skills

How do you structure application logs for production?

Use logging-best-practices for development tasks

Who is it for?

Backend engineers standardizing logs across microservices so on-call teams can trace requests during incidents.

Skip if: Metric dashboards, distributed tracing vendor setup, or frontend-only console debugging with no server log pipeline.

When should I use this skill?

The user asks for logging standards, structured logs, correlation IDs, or names logging-best-practices during observability work.

What you get

Structured log statements, level conventions, correlation ID patterns, and logging configuration aligned to observability needs.

  • Structured log code
  • Logging conventions doc

Files

SKILL.mdMarkdownGitHub ↗

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();

app.use((req, res, next) => {
  const context = {
    requestId: req.headers['x-request-id'] || uuid(),
    userId: req.user?.id
  };
  storage.run(context, next);
});

function log(level, message, meta = {}) {
  const context = storage.getStore() || {};
  logger.log(level, message, { ...context, ...meta });
}

PII Sanitization

const sensitiveFields = ['password', 'ssn', 'creditCard', 'token'];

function sanitize(obj) {
  const sanitized = { ...obj };
  for (const field of sensitiveFields) {
    if (sanitized[field]) sanitized[field] = '[REDACTED]';
  }
  if (sanitized.email) {
    sanitized.email = sanitized.email.replace(/(.{2}).*@/, '$1***@');
  }
  return sanitized;
}

Best Practices

  • Use structured JSON format
  • Include correlation IDs across services
  • Sanitize all PII before logging
  • Use async logging for performance
  • Implement log rotation
  • Never log at DEBUG in production

Additional Implementations

See references/advanced-logging.md for:

  • Python structlog setup
  • Go zap high-performance logging
  • ELK Stack integration
  • AWS CloudWatch configuration
  • OpenTelemetry tracing

Never Do

  • Log passwords or tokens
  • Use console.log in production
  • Log inside tight loops
  • Include stack traces for client errors

Related skills

FAQ

What problem does logging-best-practices solve?

logging-best-practices helps developers implement consistent, structured application logs—with useful levels and context—so production issues are easier to trace during incidents.

Does logging-best-practices configure log vendors?

logging-best-practices focuses on in-application logging patterns and conventions; shipping logs to Datadog, ELK, or CloudWatch still requires your platform integration.

Backend & APIsbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.