# Log levels are used appropriately

- **Pattern:** `ab-002312` (`saas-logging.app-logging.log-levels-appropriate`)
- **Severity:** medium
- **Lifecycle:** active
- **Last modified:** 2026-07-06
- **Canonical URL:** https://auditbuffet.com/patterns/ab-002312
- **License:** CC-BY-4.0 — attribute to AuditBuffet Pattern Catalog (https://auditbuffet.com/patterns/ab-002312)

## Why it matters

CWE-779 (Logging of Excessive Data) and CWE-778 (Insufficient Logging) sit at opposite ends of the same failure: logging everything at one level either floods your log store with noise or misses the signal entirely. OWASP A09 and NIST AU-2 both require that logged events carry enough severity context to support triage. When `error` level is used for informational messages or `info` is used for caught exceptions, alerting rules misfires — high-severity issues never trigger a page, and on-call engineers chase false alarms. The business impact is delayed incident response: teams lose the ability to distinguish a 500-rate spike from routine debug output.

## Severity rationale

Medium because miscategorized log levels degrade alert fidelity without directly exposing data, but they predictably delay incident detection and response.

## Remediation

Audit your catch blocks and log call sites and apply consistent level semantics: `error` for failures that require attention, `warn` for recoverable anomalies, `info` for significant business events, `debug` for diagnostic detail.

```ts
try {
  await processPayment(userId)
  logger.info({ userId, event: 'payment.success' }, 'Payment processed')
} catch (err) {
  logger.error({ err, userId }, 'Payment processing failed') // error — not info
}
```

Search for `logger.info` inside `catch` blocks across `app/api/` and `lib/` — those are the most common miscategorizations. Set up a Sentry alert rule on `error`-level log volume so you notice when the rate changes.

## Detection

**The detection method for this pattern is part of AuditBuffet Pro.**

The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the [Logging & Monitoring Audit](https://auditbuffet.com/audits/saas-logging). The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.

## External references

- cwe CWE-779
- cwe CWE-778
- owasp A09
- nist AU-2
- soc2 CC7.2

Taxons: observability

HTML version: https://auditbuffet.com/patterns/ab-002312
