Yesterday I found that my Apache log file in my development machine was almost 50 GB in size.
Is there a way to limit the site of the Apache log file?
This is typically done using logrotate. Example logrotate configuration for Apache:
/var/log/httpd/*log {
daily
rotate 30
compress
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
endscript
}
For Mac OS X 10.6 Snow Leopard (10.6.8),
following Onema's comment (on an answer),
I added this line to /etc/newsyslog.conf(5) (with reformatted whitespace):
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
/var/log/apache2/*_log 70:70 644 5 1000 * JG /var/run/httpd.pid
It instructs to rotate all logs (3 for me) 5 times each when over 1000 "kilobytes", using bzip2(1)
Building on Warner's suggestion, here's a logrotate config to delete your Apache logs if they grow larger than 5MB:
/var/log/httpd/*log {
size=5M
daily
}