Appropriate Log Levels
What you'll learn: How to choose the right severity level for each log message so your logs remain actionable and signal-to-noise ratio stays high.
The Four Core Levels
You've already learned what log levels are; now it's time to master when to use each one. Think of log levels like a hospital triage system—each priority dictates how urgently someone needs to respond.
ERROR: Something Broke and Requires Action
Use ERROR when a request fails, data is corrupted, or an expected operation cannot complete. These logs represent failures that need human attention. If you're woken up at 3 AM, it should be for an ERROR.
Example context: payment processing failed, database connection lost, unable to fulfill a user request.
WARN: Degraded but Still Functioning
Use WARN for recoverable issues or conditions that aren't ideal but don't stop the system. These are early warning signs—circuit breakers opening, retry attempts, deprecated API usage, or approaching resource limits.
Think of WARN as "I handled this, but something feels off."
INFO: Normal Business Events
Use INFO for key lifecycle events and business milestones: service startup, successful payment completion, user authentication, configuration changes. INFO logs tell the story of what your system did, not every step it took.
These should be sparse enough to read during normal operation.
DEBUG: Troubleshooting Detail
Use DEBUG for granular flow details useful when investigating issues: variable values, conditional branch paths, iteration counts. DEBUG is turned off in production by default and enabled when you're hunting specific bugs.
The Signal-to-Noise Problem
Overusing ERROR dilutes urgency. Overusing INFO creates noise that buries actual problems. Proper level selection keeps your logs actionable.
Key Takeaway: Use ERROR for actionable failures, WARN for degraded states, INFO for key business events, and DEBUG for troubleshooting details—choose levels based on required response, not just technical severity.