Course contentsShow
← System Design
Lesson 1129 of 1,91929. Observability: LoggingFree lesson

What to Log vs What Not to Log

Guidelines for logging decisions: capturing meaningful events while avoiding noise, performance impact, and security risks.

What to Log vs What Not to Log

You'll learn: How to distinguish between valuable logging signals and noise that degrades performance, security, or clarity.

Logging is like taking notes during a meeting—you want to capture important decisions and action items, not transcribe every breath and pause. The goal is meaningful observability without overwhelming your systems or exposing sensitive data.

What TO Log

Business-critical events: User sign-ups, purchases, authentication successes/failures, permission changes. These help track system health and user behavior.

State transitions: Order status changes, workflow progressions, job completions. You need to reconstruct what happened to any transaction.

External system interactions: API calls (with correlation IDs), database queries that fail, third-party service responses. These pinpoint integration issues.

Errors and exceptions: Stack traces, error codes, context about what the system was attempting. Include enough detail to diagnose without re-running.

Performance anomalies: Slow queries, timeout warnings, resource exhaustion signals. Log when thresholds are breached.

What NOT to Log

High-frequency routine operations: Don't log every successful cache hit or health check ping—you'll drown in noise and hurt performance.

Sensitive data: Never log passwords, credit card numbers, PII, or API keys. This creates security vulnerabilities and compliance violations.

Request/response bodies by default: Logging full payloads on every request kills performance and bloats storage. Only log bodies when debugging specific issues.

Redundant information: If your framework already logs HTTP requests, don't duplicate it. Avoid logging the same event at multiple levels.

Debug logs in production: Fine-grained debug statements should stay off unless actively troubleshooting—they create massive volumes and performance drag.

Key Takeaway: Log events that help you answer "what happened and why?" while avoiding noise, performance penalties, and security risks. Think signal-to-noise ratio—more logs ≠ better observability.