Web Hosting Talk







View Full Version : Apache logs


MattMans
02-14-2003, 08:17 PM
Hi everyone

I have a small number of virtual hosts on my dedicated Redhat 7.3 server and they all have their own access logs.

Apache httpd.conf comments say (about the main httpd access log):

The location and format of the access logfile (Common Logfile Format).
If you do not define any access logfiles within a <VirtualHost>
container, they will be logged here. Contrariwise, if you *do*
define per-<VirtualHost> access logfiles, transactions will be
logged therein and *not* in this file.

But I want to be able to save logs for each vhost, *and* have all requests logged to the main /var/log/httpd/access.log without adding another CustomLog entry to each <virtualhost>.

So to use the httpd comment as a description of what I want to do:

If you do not define any access logfiles within a <VirtualHost>
container, they will be logged here. Contrariwise, if you *do*
define per-<VirtualHost> access logfiles, transactions will be
logged therein and *also* in this file.

I won't go into why I need to do this, I just do.

I know this is a poor explanation of what I'm trying to do, but it's late and I'm tired! I hope it makes sense to someone.

Thanks

Matt (going to bed now...)

iamdotca
02-14-2003, 10:10 PM
Actually, a good question! I don't have an answer for you but I'd be interested to find out how to do this.

Prowler
02-15-2003, 12:50 AM
There are many ways of doing it. I would add a shell script to copy the access_log files of your vhosts and copy them over to a designated directory and add this to the logrotate script. This would mean that you get a copy of your vhosts' log files whenever the log 'rotates' saving you simultaneous file writes in many directories. Not many systems would have a high number of file descriptors.

Another good thing is you will copy a gunzipped file instead of a big access_log,saving you lots of disk space.

skiingyac
02-15-2003, 11:50 AM
If you want to just do it all inside apache's configuration, I think you can use the CustomLog directive multiple times in your main server configuration (as opposed to in each vhost), and use the third parameter and SetEnfIf to activate the appropriate logs. Doing all that matching shouldn't be a huge performance problem as long as your server isn't already overloaded, in which case you may need to find some fancier way. See http://httpd.apache.org/docs/mod/mod_log_config.html