Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

3 Answers

up vote 5 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
}
share|improve this answer
2  
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
add comment

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
}
share|improve this answer
add comment

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)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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