tags:

views:

256

answers:

2

Hi guys,

I need to have all PHP errors logged to a file on my centOS box. I think I'm doing everything I'm supposed to. Here's my .htaccess file:

php_flag display_errors off
php_flag log_errors On
php_flag error_log /var/www/vhosts/hostname/logs/fo_errors.log
  • In my php.ini, I have error_reporting=E_ALL set.
  • Apache does parse .htaccess
  • /var/www/vhosts/hostname/logs/fo_errors.log has owner set to apache:apache and has write permissions.

I'm out of ideas.. can anyone help?

Thanks

EDIT:

Here's the correct .htaccess file:

php_flag display_errors off 
php_flag log_errors On 
php_value error_log /var/www/vhosts/hostname/logs/fo_errors.log 
+4  A: 

You probably want to use php_value not php_flag when you set the log path. php_flag is only used for setting boolean configuration properties.

php_flag display_errors off 
php_flag log_errors On 
php_value error_log /var/www/vhosts/hostname/logs/fo_errors.log
Tom Haigh
Doh-uh! I needed a second pair of eyes to see that one. Thanks Tom.
Jahufar
Can someone edit this answer and add the corrected htaccess? This could be useful for others.
Vincent Robert
+3  A: 

Try adding the following test page to your web root:

<?php
// debug.php
echo "<pre>";
echo "log_errors = [", ini_get('log_errors'), "]\n";
echo "error_log = [", ini_get('error_log'), "]\n";
echo "writeable? ", is_writable(ini_get('error_log')) ? 'Yes' : 'No', "\n";
echo "</pre>";
error_log("Test from error_log()");
user_error("Test error from user_error()");

Browse to /debug.php and you should see the following output:

log_errors = [1]
error_log = [/var/www/vhosts//logs/fo_errors.log]
Writeable? Yes

You should also see two messages appear in your log file each time you visit the page.

too much php