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?

Thank you

link|improve this question
feedback

3 Answers

up vote 4 down vote accepted

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
}
link|improve this answer
1  
Mac OS 10.5 and up use newsyslog and the config file is located in /etc/newsyslog.conf. a man newsyslog and man newsyslog.conf should helped a lot!! – Onema Feb 18 '11 at 18:27
feedback

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
}
link|improve this answer
feedback

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)

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.