Thoughts on Apache log file sizes

log-files

Do you place any limits on the size of Apache log files – access.log and error.log?

Specifically, can you give:

  • Reasons to limit log file sizes
    • Disk space
    • Any other?
  • Reasons NOT to limit log file sizes
    • Research into performance issues or security breaches
    • Any other?
  • Methods of doing so
    • Cron job that periodically deletes the file, or the first N lines?
    • Any other?
  • Anything you might salvage before deleting
    • For example, grep out how many times a file was downloaded before deleting the access logs

I'd like get the thoughts of experienced sysadmins before I do anything.

(Marking as community wiki since this may be a matter of opinion.)

Best Answer

You should approach it in the other way, instead of limiting these log files, work out a system where there is always enough log space so that they can never fill the disk.

My primary way of doing this is simply calculating how much space is likely to be needed, and giving it lots of space, but I've also got a script which will check for diskspace in the logs directory, and if it's getting tight will automatically rotate the log files, compress old versions, and erase those which are old enough that they'll be on archived media.