error_log per Virtual Host?

Michael Stum picture Michael Stum · Aug 1, 2008 · Viewed 101.2k times · Source

On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts with separate log files. We cannot seem to separate the php error_log between virtual hosts.

Overriding this setting in the <Location> of the httpd.conf does not seem to do anything.

Is there a way to have separate php error_logs for each Virtual Host?

Answer

Clutch picture Clutch · Aug 26, 2010

If somebody comes looking it should look like this:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/domains/example.com/html
    ErrorLog /var/www/domains/example.com/apache.error.log
    CustomLog /var/www/domains/example.com/apache.access.log common
    php_flag log_errors on
    php_flag display_errors on
    php_value error_reporting 2147483647
    php_value error_log /var/www/domains/example.com/php.error.log
</VirtualHost>

This is for development only since display_error is turned on. You will notice that the Apache error log is separate from the PHP error log. The good stuff is in php.error.log.

Take a look here for the error_reporting key http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting