1

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?

1 Answer 1

3

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .