← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

Log Levels & When to Use Each

Observability Beginner
debt(d7/e3/b5/t5)
d7 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'only careful code review or runtime testing' (d7). The detection_hints indicate automated detection is 'no' and the only listed tool is Monolog, which is a logging library, not a static analyzer that flags wrong log levels. Misuse (e.g., logging 401s as ERROR) is invisible to compilers, linters, and most SAST tools — it only becomes apparent during code review or when alert fatigue / missed incidents surface in production.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix provides a direct mapping rule (4xx=INFO, 5xx=ERROR, etc.). Fixing a mis-levelled log call is a targeted find-and-replace across call sites, but it may touch multiple files where the same wrong pattern is repeated — slightly more than a single-line patch but well within one component or a consistent pattern replacement.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). Log levels apply across web, cli, and queue-worker contexts. Getting them wrong persistently degrades observability across all work streams — alert thresholds, on-call runbooks, and dashboards are all shaped by the level choices. It doesn't define the entire system shape, but consistently wrong levelling creates ongoing friction for every engineer touching monitoring or incident response.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap' (t5). The misconception field directly identifies the canonical trap: WARNING and ERROR are treated as interchangeable by many developers. This is a documented, well-known gotcha (PSR-3 defines the distinction, yet common_mistakes confirm developers routinely log 401s as ERROR or use CRITICAL for recoverable errors). It contradicts intuition but is a learnable, documented rule rather than a catastrophic always-wrong pattern.

About DEBT scoring →

TL;DR

Log levels (DEBUG, INFO, WARNING, ERROR, CRITICAL) communicate severity — use the right level so alerts fire on real issues and noise doesn't mask real problems.

Explanation

Standard levels (RFC 5424 / PSR-3): EMERGENCY (system unusable), ALERT (immediate action needed), CRITICAL (component failure), ERROR (operation failed, handled), WARNING (unexpected but recovered), NOTICE (normal but significant), INFO (business events, milestones), DEBUG (developer details, queries, input). Production: log INFO and above. Development: log DEBUG and above. Rules: ERROR = operation that failed and was caught (payment declined). WARNING = degraded behaviour (cache miss, rate limited). INFO = key business events (order placed, user registered). DEBUG = everything else. CRITICAL = component down (DB, cache unavailable).

Common Misconception

WARNING and ERROR are interchangeable — WARNING means 'something unusual but handled'; ERROR means 'an operation failed'. Wrong level = wrong alert thresholds.

Why It Matters

Using the right log level ensures alerts fire on real failures (ERROR/CRITICAL) and don't fire on normal degradation (WARNING) — mis-levelled logs cause alert fatigue or missed incidents.

Common Mistakes

  • Logging expected user errors as ERROR — 401 Unauthorized is INFO, not ERROR.
  • Not logging at INFO for key business events — hard to audit.
  • DEBUG logs in production — performance and cost impact.
  • CRITICAL for recoverable errors — saves CRITICAL for actual outages.

Code Examples

✗ Vulnerable
Log::error('User login failed'); // Expected behaviour — should be INFO/WARNING
Log::debug('Processing payment', $data); // In production — noise
✓ Fixed
Log::info('User login failed', ['user_email' => $email, 'reason' => 'wrong_password']);
Log::error('Payment gateway timeout', ['order_id' => $orderId, 'gateway' => 'stripe']);
Log::critical('Database connection failed', ['host' => $dbHost]);

// In config — production:
// monolog.level: info (suppresses debug)

Added 23 Mar 2026
Views 56
Rate this term
No ratings yet
DEV INTEL Tools & Severity
🟡 Medium ⚙ Fix effort: Low
⚡ Quick Fix
Map HTTP errors: 4xx=INFO, 5xx=ERROR. Map business errors: validation=INFO, payment_failed=WARNING, payment_timeout=ERROR. Map system: component_down=CRITICAL. Disable DEBUG in production.
📦 Applies To
web cli queue-worker
🔗 Prerequisites
🔍 Detection Hints
Log::error|log->error
Auto-detectable: ✗ No monolog
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: Low Context: Line


✓ schema.org compliant