Home > Articles > Networking > Network Administration & Management

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Keeping Separate Logs for Each Virtual Host


   ServerName vhost1.example.com

   CustomLog logs/vhost1.example.com_log combined

   ErrorLog logs/vhost2.example.com_log


   </Virtual Host>

You can keep separate access logs for each virtual host using a CustomLog directive inside each <VirtualHost> section, as shown in the example.

You can also choose to log the operations of all virtual hosts in the access_log defined in the global server context:

LogFormat "%v %h %l %u %t \"%r\" %>s %b" common_virtualhost
CustomLog logs/access_log common_virtualhost

%v will log the name of the virtual host that serves the request. You can then use the tools described in the previous section to process the resulting log file. This may be necessary if you have a large number of virtual hosts.

If you don't want to keep track of the operations of a particular host at all, you can simply use

CustomLog /dev/null
  • + Share This
  • 🔖 Save To Your Account