Linux

Sometimes, it is ideal to have logs for each virtual host. It would be a great deal when debugging applications or just seeing the logs available for your virtual host.

Create Logs for Your Virtual Host

To create a custom log for your Virtual Host, directives should be placed within a <VirtualHost> section.

<VirtualHost *:80>
    ServerName   example.com
    DocumentRoot /var/www/example
    ErrorLog     logs/example.com-error_log
    CustomLog   logs/example.com-access_log combined
</VirtualHost>

Now, when you need to access the logs, you will find them in /var/logs/httpd/example.com-error_log and /var/logs/httpd/example.com-access_log rather than the default log files.