Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this directive on each of my virtual host. It is eating all my hard drive space very very quickly and have to clear it manually. I need some directives added to my ghosts.

For each virtual host in httpd_vhosts.conf, I have this line.

ErrorLog /Library/WebServer/thisHostsDirectory/err_thisvhost.log
  1. How do I tell apache to clear the log every xx days.
  2. How do I add in the directive to log the remote IP on this log
  3. How do I exclude my localhost and other specific IPs on this log.

Thank you.

share|improve this question
What's filling the log? Fix the root cause, not the symptom - the error log typically won't be terribly large. – Shane Madden Jan 31 '12 at 17:18
Its that particular line above. I had to delete that log (475gb) yesterday. I have 3 vhosts in one Lion server. – maximo Jan 31 '12 at 17:20
Funny thing is, it does not happen on the other server running Leopard where I have 3 vhosts. Only on the new Lion Server. Have the same directive except I am using the Lion as proxy for the Leopard. – maximo Jan 31 '12 at 17:24
That line directs the Apache server to place the error log there - the error log must be somewhere, so that line is not the issue. What I'm looking to find out is the contents of that log file - it's completely abnormal for it to get that large. Most likely you've got something like LogLevel debug configured somewhere, or a bot making an enormous number of requests to a nonexistant file. Let's get a small sampling of the log - run tail /Library/WebServer/thisHostsDirectory/err_thisvhost.log in the terminal application. – Shane Madden Jan 31 '12 at 17:26
OK - I just ran it and this what I got. It was emptied yesterday. – maximo Jan 31 '12 at 17:34

Here is the way to rotate Apache logs :

ErrorLog "|bin/rotatelogs /var/logs/errorlog.%Y-%m-%d-%H_%M_%S 5M" 

The documentation has everything you need:

share|improve this answer
Shall I add it to each vhost before my err log line? – maximo Jan 31 '12 at 18:08

The normal way to handle this is to add the webserver logfile to rotatelogs. This rotates the log either after set size reached and|or after a set time.

Do a man rotatelogs on your system to find out how this works.

UPDATE Just forgot to mention that you should pipe the rotated logfile to a compression program to get the logs archived.

About what to add just check the documentation here: and here:

To answer your 2.) you would have to add a %a in your CustomLog directive. For 3.) someone else might suggest a solution. I'd pipe the output to awk or sed and remove the lines starting with either and|or localhost. But there might be better ways.

share|improve this answer

Your Answer


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.