0

I'm a little new to this, but our previous developers didn't set up the vhost logs to rotate (or Apache was configured wrong) so while the default logs rotate, the vhost ones do not.

I was reading about how to configure logrotate.d (CentOS 4.x) and I thought I could create a new file "vhosts" with a line like this:

/var/log/httpd/*/*log

However, in the httpd file, it has this: /var/log/httpd/*log

I'm afraid that my line will conflict with the httpd code, because it will also rotate log files in the httpd folder. I would rather not have to add the path for each vhost as we may add a new vhost at any time.

Here's what the folder looks like (all domain sub-folders contain access_log and error_log):

ls -l /var/log/httpd

-rw-r--r-- 1 root root      0 Sep 27  2012 access_log
-rw-r--r-- 1 root root   4743 Sep  9  2012 access_log-20120909
-rw-r--r-- 1 root root 106443 Sep 16  2012 access_log-20120916
-rw-r--r-- 1 root root  24832 Sep 23  2012 access_log-20120923
-rw-r--r-- 1 root root  11671 Sep 26  2012 access_log-20120927
drwxr-xr-x 2 root root   4096 Jul  2  2012 domain1
drwxr-xr-x 2 root root   4096 Nov 13  2012 domain2
drwxr-xr-x 2 root root   4096 Sep 26  2012 domain3
drwxr-xr-x 2 root root   4096 Sep  6  2012 domain4
-rw-r--r-- 1 root root    431 Aug 11 03:07 error_log
-rw-r--r-- 1 root root   1086 Jul 21 03:06 error_log-20130721
-rw-r--r-- 1 root root   2007 Jul 28 03:13 error_log-20130728
-rw-r--r-- 1 root root    893 Aug  4 03:18 error_log-20130804
-rw-r--r-- 1 root root    583 Aug 11 03:07 error_log-20130811
-rw-r--r-- 1 root root      0 Aug 11 03:07 ssl_access_log
-rw-r--r-- 1 root root   2043 Jul 21 01:07 ssl_access_log-20130721
-rw-r--r-- 1 root root   1725 Jul 28 03:11 ssl_access_log-20130728
-rw-r--r-- 1 root root   1244 Aug  3 19:29 ssl_access_log-20130804
-rw-r--r-- 1 root root    794 Aug 10 12:17 ssl_access_log-20130811
-rw-r--r-- 1 root root    227 Aug 11 03:07 ssl_error_log
-rw-r--r-- 1 root root   1049 Jul 21 01:07 ssl_error_log-20130721
-rw-r--r-- 1 root root   1078 Jul 28 03:11 ssl_error_log-20130728
-rw-r--r-- 1 root root    330 Aug  3 16:02 ssl_error_log-20130804
-rw-r--r-- 1 root root    673 Aug 10 12:17 ssl_error_log-20130811
-rw-r--r-- 1 root root      0 Aug 11 03:07 ssl_request_log
-rw-r--r-- 1 root root   2091 Jul 21 01:07 ssl_request_log-20130721
-rw-r--r-- 1 root root   1705 Jul 28 03:11 ssl_request_log-20130728
-rw-r--r-- 1 root root   1193 Aug  3 19:29 ssl_request_log-20130804
-rw-r--r-- 1 root root    827 Aug 10 12:17 ssl_request_log-20130811
2
  • Please show us a listing of /var/log/httpd (ls -lR /var/log/httpd). It's unclear what is located where on your system. You'll have to find an expression to filter out the vhost logs obviously.
    – Marki
    Aug 11, 2013 at 20:17
  • also in the <Virtual Host> configuration you can place TransferLog ,ErrorLog and CustomLog options to specify the location and name of the file. You'll need to create those files with the correct permissions or else apache won't start Aug 11, 2013 at 20:30

1 Answer 1

0

I guess in that case the pattern

/var/log/httpd/*/*log

for logrotate should work just fine.

You can check yourself what would be impacted by just issung a

ls -l /var/log/httpd/*/*log

The following shows what logrotate would do

logrotate -dv /etc/logrotate.d/vhosts
2
  • Thanks, I'll see how that works. I set rotate 60 then tried the logrotate debug and it showed that it would save 60 different log files! Am I reading this right? Really I just want to save logs for 60 days.
    – Davicus
    Aug 12, 2013 at 1:11
  • Probably, and if you look at it closely, it shows what it would do if all those 60 days of files were there, per file (expanded from /var/log/*/*log). So it should show nx60 rotations where n is the number of files matched by your expression. Please don't hesitate to mark this answer as accepted if it now indeed is.
    – Marki
    Aug 12, 2013 at 10:19

You must log in to answer this question.

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