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

Insufficient Logging & Monitoring

security CWE-778 OWASP A9:2021 CVSS 6.5 Beginner
debt(d7/e5/b5/t7)
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 note `automated: no` and while tools like semgrep, splunk, and datadog are listed, they require manual configuration of rules and baselines — they don't catch missing logging out of the box. Absence of logging is structural and requires deliberate audit of code paths rather than a single tool scan.

e5 Effort Remediation debt — work required to fix once spotted

Closest to 'touches multiple files / significant refactor in one component' (e5). The quick_fix identifies specific event categories to log (auth, access control, validation failures), but adding structured, contextual logging across authentication flows, access control checks, and input validation paths in a web/API codebase touches many files and requires consistent patterns. It's more than a one-line fix but not a full architectural rework.

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

Closest to 'persistent productivity tax' (b5). Applies to web and API contexts broadly. Insufficient logging creates an ongoing operational burden — every incident investigation is harder, alert rules cannot be written, and dashboards are impossible. It slows down security and ops work streams continuously but doesn't reshape every feature's development the way a foundational architectural choice would.

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

Closest to 'serious trap' (t7). The misconception field captures it precisely: developers believe logging only matters after a breach, when in fact logs are the primary real-time detection mechanism. This contradicts the intuition that logging is a post-hoc forensic tool, and the common mistakes show multiple independent ways to get it wrong (wrong level, missing context, unstructured, logging sensitive data) — each feeling 'good enough' while silently failing.

About DEBT scoring →

Also Known As

missing logging inadequate monitoring no audit trail

TL;DR

Failure to log security events and monitor them allows attacks to go undetected and unresponded to.

Explanation

Without adequate logging of authentication attempts, access control failures, input validation errors, and administrative actions, attackers can operate undetected for extended periods — the industry average time to detect a breach is over 200 days. Effective security logging must be tamper-resistant, centralised, include timestamps and user context, and be actively monitored with alerts for anomalous patterns. In PHP, use a structured logging library such as Monolog and ship logs to a separate SIEM rather than writing to local files.

Common Misconception

Logging only matters after a breach occurs. Insufficient logging means breaches go undetected for months — logs are the primary mechanism for both real-time detection and forensic investigation.

Why It Matters

Good logs are your eyes during an incident — without structured, contextual logging you are debugging in the dark. Bad logs (too verbose, too sparse, or unstructured) are as useless as no logs at all.

Common Mistakes

  • Logging everything at DEBUG level in production — log volume makes finding signal impossible and inflates costs.
  • Not including context (user ID, request ID, correlation ID) — a log line without context cannot be traced to a cause.
  • Using string concatenation instead of structured logging — machine-readable logs enable alerting and dashboards.
  • Logging sensitive data (passwords, tokens, PII) — logs are often stored less securely than databases.

Code Examples

✗ Vulnerable
// Silent failure — no trace of what happened
public function login(string \$email, string \$password): ?User {
    \$user = User::where('email', \$email)->first();
    if (!\$user || !password_verify(\$password, \$user->password)) {
        return null; // attacker can try forever undetected
    }
    return \$user;
}
✓ Fixed
public function login(string \$email, string \$password): ?User {
    \$user = User::where('email', \$email)->first();
    if (!\$user || !password_verify(\$password, \$user->password)) {
        \$this->logger->warning('Failed login attempt', [
            'email' => \$email,
            'ip'    => request()->ip(),
            'ua'    => request()->userAgent(),
        ]);
        return null;
    }
    \$this->logger->info('User logged in', ['user_id' => \$user->id, 'ip' => request()->ip()]);
    return \$user;
}

Added 13 Mar 2026
Edited 22 Mar 2026
Views 53
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings T 1 ping W 0 pings T 0 pings F 0 pings S 0 pings S 0 pings M 0 pings T 0 pings W 1 ping T 0 pings F 2 pings S 1 ping S 0 pings M 0 pings T 0 pings W 1 ping T 1 ping F 0 pings S 0 pings S 0 pings M 0 pings T 1 ping W 1 ping T 0 pings F 1 ping S 3 pings S 2 pings M 1 ping T 0 pings W
No pings yet today
Scrapy 1
Amazonbot 9 Scrapy 8 Perplexity 6 ChatGPT 5 SEMrush 4 Ahrefs 3 Unknown AI 3 Google 2 Majestic 1 Bing 1 Meta AI 1
crawler 39 crawler_json 3 pre-tracking 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Medium
⚡ Quick Fix
Log authentication events (login success/fail, password reset, MFA), all access control failures, and all input validation failures — these are exactly the events you need to detect and investigate a breach
📦 Applies To
any web api
🔗 Prerequisites
🔍 Detection Hints
No logging on failed login attempts; access control failure not logged; no audit trail for privileged operations; OWASP A9:2021 insufficient logging
Auto-detectable: ✗ No semgrep splunk datadog
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: High ✗ Manual fix Fix: Medium Context: File
CWE-778 CWE-223

✓ schema.org compliant