Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
General / UtilitybeginnerNew

Logger Setup

Share

Set up application logger

Works with OpenClaude

You are a backend/full-stack developer setting up structured logging for an application. The user wants to configure a production-ready logger with appropriate log levels, output formats, and transport mechanisms.

What to check first

  • Check if winston or pino is already installed via npm list winston or npm list pino
  • Verify Node.js version supports your chosen logging library (Node 12+)
  • Determine if logs should go to console, files, or external services (Datadog, CloudWatch, etc.)

Steps

  1. Install a logging library: npm install winston (or npm install pino for high-performance logging)
  2. Create a logger.js or logger.ts file in your src/ or config/ directory
  3. Configure log levels: error, warn, info, http, debug, silly (Winston) or fatal, error, warn, info, debug, trace (Pino)
  4. Set up transports (Winston) or streams (Pino) to define where logs are written (console, file, or external service)
  5. Add timestamp formatting to each log entry for traceability
  6. Configure log format as JSON for machine parsing or readable text for development
  7. Export the logger instance and import it wherever logging is needed
  8. Set the log level via environment variable (e.g., LOG_LEVEL=debug) so it's configurable per environment

Code

// logger.js (Winston setup)
const winston = require('winston');
const path = require('path');

const logLevel = process.env.LOG_LEVEL || 'info';
const isDevelopment = process.env.NODE_ENV === 'development';

const logger = winston.createLogger({
  level: logLevel,
  format: winston.format.combine(
    winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }),
    winston.format.errors({ stack: true }),
    isDevelopment
      ? winston.format.simple()
      : winston.format.json()
  ),
  defaultMeta: { service: 'my-app' },
  transports: [
    new winston.transports.Console({
      format: isDevelopment
        ? winston.format.combine(
            winston.format.colorize(),
            winston.format.printf(
              ({ timestamp, level, message, ...meta }) =>
                `${timestamp} [${level}]: ${message} ${
                  Object.keys(meta).length ? JSON.stringify(meta, null, 2) : ''
                }`
            )
          )
        : winston.format.json(),
    }),
    new winston.transports.File({
      filename: path.join('logs', 'error.log'),
      level: 'error',
      format: winston.format.json(),
    }),
    new winston.transports.File({
      filename: path.join('logs', '

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
generalloggingsetup

Install command:

curl -o ~/.claude/skills/logger-setup.md https://claude-skills-hub.vercel.app/skills/general/logger-setup.md

Related General / Utility Skills

Other Claude Code skills in the same category — free to download.

Want a General / Utility skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.