<p>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 <code>error_log</code> between virtual hosts.</p>

<p>Overriding this setting in the <code>&lt;Location&gt;</code> of the <code>httpd.conf</code> does not seem to do anything.</p>

<p>Is there a way to have separate php <code>error_logs</code> for each Virtual Host?</p>

[{'answer_id': 207, 'author': 'helloandre', 'author_id': 50, 'author_profile': 'https://Stackoverflow.com/users/50', 'pm_score': 7, 'selected': True, 'text': '<p>To set the <em>Apache</em> (<em>not the PHP</em>) log, the easiest way to do this would be to do:</p>\n\n<pre><code>&lt;VirtualHost IP:Port&gt;\n   # Stuff,\n   # More Stuff,\n   ErrorLog /path/where/you/want/the/error.log\n&lt;/VirtualHost&gt;\n</code></pre>\n\n<p>If there is no leading "/" it is assumed to be relative.</p>\n\n<p><a href="http://httpd.apache.org/docs/1.3/mod/core.html#errorlog" rel="noreferrer">Apache Error Log Page</a></p>\n'}, {'answer_id': 236, 'author': 'Mat', 'author_id': 48, 'author_profile': 'https://Stackoverflow.com/users/48', 'pm_score': 3, 'selected': False, 'text': "<p>The default behaviour for error_log() is to output to the Apache error log. If this isn't happening check your php.ini settings for the error_log directive. Leave it unset to use the Apache log file for the current vhost.</p>\n"}, {'answer_id': 297, 'author': 'Kevin', 'author_id': 40, 'author_profile': 'https://Stackoverflow.com/users/40', 'pm_score': 4, 'selected': False, 'text': '<p>I usually just specify this in an <code>.htaccess</code> file <em>or</em> the <code>vhost.conf</code> on the domain I\'m working on. Add this to one of these files:</p>\n\n<pre><code>php_admin_value error_log "/var/www/vhosts/example.com/error_log"\n</code></pre>\n'}, {'answer_id': 6568, 'author': 'ejunker', 'author_id': 796, 'author_profile': 'https://Stackoverflow.com/users/796', 'pm_score': 2, 'selected': False, 'text': '<p>My Apache had something like this in httpd.conf. Just change the ErrorLog and CustomLog settings </p>\n\n<pre><code>&lt;VirtualHost myvhost:80&gt;\n    ServerAdmin webmaster@dummy-host.example.com\n    DocumentRoot /opt/web\n    ServerName myvhost\n    ErrorLog logs/myvhost-error_log\n    CustomLog logs/myvhost-access_log common\n&lt;/VirtualHost&gt;\n</code></pre>\n'}, {'answer_id': 34044, 'author': 'hoyhoy', 'author_id': 3499, 'author_profile': 'https://Stackoverflow.com/users/3499', 'pm_score': 3, 'selected': False, 'text': "<p>Try adding the <code>php_value error_log '/path/to/php_error_log</code> to your VirtualHost configuration.</p>\n"}, {'answer_id': 118200, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': "<p>You can try:</p>\n<pre><code>    &lt;VirtualHost myvhost:80&gt;\n       php_value error_log &quot;/var/log/httpd/vhost_php_error_log&quot;\n    &lt;/Virtual Host&gt;\n</code></pre>\n<p>But I'm not sure if it is going to work. I tried on my sites with no success.</p>\n"}, {'answer_id': 118222, 'author': 'James Hartig', 'author_id': 45530, 'author_profile': 'https://Stackoverflow.com/users/45530', 'pm_score': 3, 'selected': False, 'text': '<p>Yes, you can try,</p>\n\n<pre><code>php_value error_log "/var/log/php_log" \n</code></pre>\n\n<p>in <code>.htaccess</code> or you can have users use <code>ini_set()</code> in the beginning of their scripts if they want to have logging.</p>\n\n<p>Another option would be to enable scripts to default to the <code>php.ini</code> in the folder with the script, then go to the user/host\'s root folder, then to the server\'s root, or something similar. This would allow hosts to add their own <code>php.ini</code> values and their own <code>error_log</code> locations.</p>\n'}, {'answer_id': 1077264, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<pre><code>php_value error_log "/var/log/httpd/vhost_php_error_log"\n</code></pre>\n\n<p>It works for me, but I have to change the permission of the log file.</p>\n\n<p>or Apache will write the log to the its <code>error_log</code>.</p>\n'}, {'answer_id': 2569128, 'author': 'rkulla', 'author_id': 308062, 'author_profile': 'https://Stackoverflow.com/users/308062', 'pm_score': 3, 'selected': False, 'text': '<p>Don\'t set <code>error_log</code> to where your <code>syslog</code> stuff goes, <code>eg /var/log/apache2</code>, because they errors will get intercepted by <code>ErrorLog</code>. Instead, create a <code>subdir</code> in your <em>project folder</em> for logs and do <code>php_value</code> <code>error_log "/path/to/project/logs"</code>. This goes for both <code>.htaccess</code> <em>files and vhosts</em>. Also make sure you put <code>php_flag</code> <code>log_errors</code> on</p>\n'}, {'answer_id': 3576664, 'author': 'Clutch', 'author_id': 25143, 'author_profile': 'https://Stackoverflow.com/users/25143', 'pm_score': 7, 'selected': False, 'text': '<p>If somebody comes looking it should look like this:</p>\n<pre><code>&lt;VirtualHost *:80&gt;\n    ServerName example.com\n    DocumentRoot /var/www/domains/example.com/html\n    ErrorLog /var/www/domains/example.com/apache.error.log\n    CustomLog /var/www/domains/example.com/apache.access.log common\n    php_flag log_errors on\n    php_flag display_errors on\n    php_value error_reporting 2147483647\n    php_value error_log /var/www/domains/example.com/php.error.log\n&lt;/VirtualHost&gt;\n</code></pre>\n<p>This is for <em>development only</em> since <code>display_error</code> is turned on. You will notice that the Apache error log is separate from the PHP error log. The good stuff is in <code>php.error.log</code>.</p>\n<p>Take a look here for the <code>error_reporting</code> key <a href="http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting" rel="noreferrer">http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-reporting</a></p>\n'}, {'answer_id': 50618440, 'author': 'Parveen Chauhan', 'author_id': 7013481, 'author_profile': 'https://Stackoverflow.com/users/7013481', 'pm_score': 2, 'selected': False, 'text': '<p>Create Simple VirtualHost:</p>\n\n<p>example hostname:- <code>thecontrolist.localhost</code></p>\n\n<ol>\n<li><p>C:\\Windows\\System32\\drivers\\etc</p>\n\n<p><code>127.0.0.1 thecontrolist.localhost</code>    in hosts file </p></li>\n<li><p>C:\\xampp\\apache\\conf\\extra\\httpd-vhosts.conf </p>\n\n<pre><code>&lt;VirtualHost *&gt;\n  ServerName thecontrolist.localhost\n  ServerAlias thecontrolist.localhost\n  DocumentRoot "/xampp/htdocs/thecontrolist"\n  &lt;Directory "/xampp/htdocs/thecontrolist"&gt;\n    Options +Indexes +Includes +FollowSymLinks +MultiViews\n    AllowOverride All\n    Require local\n  &lt;/Directory&gt;\n&lt;/VirtualHost&gt;\n</code></pre></li>\n<li><p>Don\'t Forget to restart Your apache. \nfor more <a href="https://wiki.apache.org/httpd/ExampleVhosts" rel="nofollow noreferrer">check</a> this link</p></li>\n</ol>\n'}]
['https://Stackoverflow.com/questions/176', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/91/']