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.

I would like a solution to my problem where i have 100s of domains on an apache server. I don't want a separate log file for each domain i want them to share a log file. This is easy enough if i don't need to rotate them. For instance i can use

CustomLog "/var/log/apache2/access_log" "%h %v %l %u %t \"%r\" %>s %b" ErrorLog "/var/log/apache2/error_log"

This works fine but i used this and noticed that my log file is 6GB. So i want the log files to be rotated with the apache program rotatelogs. So I tried to add some rotation on one of my virtual hosts.

CustomLog '|/usr/sbin/rotatelogs "/var/log/apache2/access_log" 604800 0' "%h %v %l %u %t \"%r\" %>s %b"

The problem was that it added some numbers after the access_log so the other domains didn't write to the same file as the rotated one. Is there some way of having all the domains write to the same file and have the file rotated? if i put the log rotate in to all the virtual hosts will it use the same file or will each domain overwrite the file? What should i do with the 6GB access_log?

share|improve this question
add comment

1 Answer

The answer in the end was...

To use global logging instead of per virtual host logging. I commented out all the Custom Logs and Error logs from the virtual hosts then in the httpd.conf i added

CustomLog '|/usr/sbin/rotatelogs "/var/log/apache2/access_log.%Y-%m-%d" 604800 0' "%h %v %l %u %t \"%r\" %>s %b"

ErrorLog '|/usr/sbin/rotatelogs "/var/log/apache2/error_log.%Y-%m-%d" 604800 0'

This did the trick

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.