Oversized log files are difficult to analyze

If you're like me, when a web access related problem strikes, my quickest path to diagnosing the issue is to open up Apache log files with vi or nano.

This happened to me the other day, and I was surprised to find that even though my logs rotate out weekly, the rotated files were still almost 1GB in size.

So, it got me thinking. Why do I have 4 log files, one for each of the past 4 weeks. When a problem strikes, I always solve it within 24 hours. Google analytics takes care of the traffic analysis.

I decided to opt for daily log rotation, and only keep the most recent 7 days. This will cut my log size down to 25% it's original size, and make them far less time and memory consuming to open via the command line.

A snippet from /etc/logrotate.conf

# rotate log files weekly
daily

# keep 4 weeks worth of backlogs
rotate 7

Why follow me on Twitter?

  • I tweet about new technologies, services or libraries I find interesting
  • Yeah, sometimes I'll post a pet-peeve or rant about something trivial
  • If I discover something that made my web development life easier, I share it
  • I'll shout out any handy tip that I think might be useful to other devs


Tagged .

Updated: 2012-06-28

Phil LaNasa follow us in feedly