---
title: Do Not Use Error Log For Non-critical
impact: HIGH
impactDescription: prevents alert fatigue and log noise
tags: logging, log-levels, error, observability, quality, php
---

## Do Not Use Error Log For Non-critical

Using the `error` log level for non-critical or expected business events (like wrong passwords or validation failures) creates noise and causes alert fatigue. When too many non-critical events are logged as errors, real system failures may be overlooked.

**Incorrect (overusing ERROR level):**

```php
// NOT an error - expected business behavior
Log::error('User entered wrong password', ['user_id' => $id]);

// NOT an error - validation failure
Log::error('Validation failed for email format', ['email' => $email]);

// NOT an error - temporary network retry
Log::error('Retrying external API call... attempt 2');
```

**Correct (appropriate PSR-3 log levels):**

```php
// WARNING - Pathological but recoverable scenarios
Log::warning('API timeout, retrying...', ['attempt' => 2, 'service' => 'payment-gateway']);

// INFO - Significant business events
Log::info('Login failed: invalid credentials', ['username' => $username, 'attempts' => 3]);

// DEBUG - Information helpful for developers during troubleshooting
Log::debug('Form validation failed', ['field' => 'email', 'error' => 'invalid_format']);

// ERROR - Actual system failures that require attention
Log::error('Database connection lost', ['host' => $host, 'exception' => $e->getMessage()]);

// CRITICAL/EMERGENCY - System unusable or widespread failure
Log::emergency('Server out of disk space!');
```

**Log Level Guide (PSR-3):**

| Level | Use For | Action Required? |
|-------|---------|------------------|
| **EMERGENCY/CRITICAL** | System is unusable, widespread failure | Immediate wake-up call |
| **ERROR** | Runtime errors that do not require immediate action but should be logged | Investigation within regular hours |
| **WARNING** | Exceptional occurrences that are not errors (deprecations, retries) | Periodic review |
| **INFO** | Interesting events (Logins, SQL logs in dev) | None (monitoring only) |
| **DEBUG** | Detailed debug information | Temporary use |

**Tools:** Monolog, Laravel/Symfony Logging, Sentry, New Relic
