Why Your Logs Are Costing Too Much
Best Practices September 19, 2025 · 2 min read

Why Your Logs Are Costing Too Much

Log costs spiraling out of control? Learn why it happens and how to reduce logging expenses without losing visibility.

Log management costs can sneak up on you. What starts as a reasonable expense can balloon as your application grows. Understanding why logs cost so much—and how to optimize—can save you hundreds or thousands of dollars monthly.

Why Log Costs Spiral

1. Verbose Default Settings

Most frameworks default to debug-level logging. In production, you're paying to store logs you'll never read.

2. Log Everything Mentality

"We might need it someday" leads to logging every database query, every API response, every cache hit. You won't need 99% of it.

3. Duplicate Information

Logging the same data in multiple places—application logs, web server logs, and load balancer logs all capturing the same request.

4. Long Retention Periods

Keeping logs for months or years when most debugging happens within hours or days of an incident.

Calculating Your True Costs

Estimate your monthly log volume:

Daily logs × 30 days = Monthly volume
Monthly volume × $/GB = Monthly cost

Example:
500MB/day × 30 = 15GB/month
15GB × $0.50/GB = $7.50/month  ← Reasonable

But at scale:
5GB/day × 30 = 150GB/month
150GB × $0.50/GB = $75/month  ← Getting expensive

Cost Reduction Strategies

1. Adjust Log Levels

# Development
LOG_LEVEL=debug

# Production
LOG_LEVEL=warning

This alone can reduce log volume by 80%+.

2. Sample High-Frequency Events

// Log 1% of successful requests
if (rand(1, 100) === 1) {
    Log::info('Request completed', $context);
}

// Always log errors
Log::error('Request failed', $context);

3. Reduce Retention

Most debugging happens within 48 hours. Consider:

  • Error logs: 30 days
  • Warning logs: 14 days
  • Info logs: 7 days
  • Debug logs: Don't store in production

4. Aggregate Instead of Individual Logs

Instead of logging every request:

// Bad: 1 log per request
Log::info('Request', ['path' => '/api/users', 'duration' => 45]);

// Better: Aggregate and log summary
// (Use metrics for request counts, only log anomalies)

5. Exclude Noise

Filter out logs that provide no value:

  • Health check endpoints
  • Static asset requests
  • Expected 404s (favicon.ico, robots.txt)
  • Automated monitoring requests

Cost Comparison by Provider

VolumeDatadogLoggly401 Clicks
5 GB/mo$50+$79$19
25 GB/mo$200+$159$49
100 GB/mo$500+Custom$99

The Right Approach

  1. Audit current logging: What are you actually logging?
  2. Categorize by value: What logs have you actually used?
  3. Reduce ruthlessly: Remove low-value logs
  4. Monitor volume: Track GB/day trends
  5. Right-size retention: Match retention to actual needs

Conclusion

Logging costs are controllable. The key is logging what matters, not everything. A well-tuned logging strategy gives you better visibility at lower cost than verbose logging that drowns you in noise.

A

Admin

Published on September 19, 2025