- Introduction to Logging in Apache
- Default Apache Log Files
- Creating Log Formats
- Creating a Custom Log File
- Redirecting Logs to an External Program
- Logging Requests Conditionally
- Monitoring Who Is Linking to Your Website
- Monitoring Apache with mod_status
- Monitoring Apache with SNMP
- Analyzing Your Logs with Open-source Tools
- Monitoring Your Logs in Real Time
- Logging Requests to a Database
- Rotating and Archiving Logs
- Controlling IP Address Resolution
- Processing Logged IP Addresses
- Restarting Apache Automatically If It Fails
- Merging and Splitting Log Files
- Keeping Separate Logs for Each Virtual Host
- Common Log Entries
Keeping Separate Logs for Each Virtual Host
<VirtualHost 192.168.200.3> 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