---
title: Use Appropriate Log Levels
impact: MEDIUM
impactDescription: facilitates effective monitoring and troubleshooting
tags: logging, observability, monitoring, quality
---

## Use Appropriate Log Levels

Use the correct log level (`debug`, `info`, `warn`, `error`, `fatal`) to distinguish between operational noise and critical issues.

**Incorrect (misused levels):**

```ruby
begin
  process_data
rescue => e
  Rails.logger.info "Error happened: #{e.message}" # Error logged as Info
end

Rails.logger.error "Variable x is #{x}" # Debugging info logged as Error
```

**Correct (appropriate levels):**

```ruby
Rails.logger.debug "Processing payload: #{payload}"

begin
  process_data
rescue => e
  Rails.logger.error "Data processing failed: #{e.message}"
end

if retry_count > 0
  Rails.logger.warn "Retry attempt #{retry_count} for user #{user_id}"
end
```

**Tools:** Manual Review
---
