Reputation: 91
I am trying to log all the errors but for some reason I cannot get it to work! If I turn on display_errors in my .htaccess then errors pop up here and there. But instead of having them on display, I want them to be put in a log that I can read so that my users do not see the errors.
I have added these to my .htaccess file:
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag log_errors on
php_flag ignore_repeated_errors off
php_flag ignore_repeated_source off
php_flag report_memleaks on
php_flag track_errors on
php_value docref_root 0
php_value docref_ext 0
php_value error_log /path/to/errors.txt
php_value error_reporting 32767
php_value log_errors_max_len 2048
Yet errors.log is still empty! Ive tried restarting apache, whole server, nothing. Any help would be greatly appreciated.
PHP Version - 5.4.39-0+deb7u2
Upvotes: 1
Views: 300
Reputation: 4696
It is most likely a permissions issue as to why the errors are not logging. Here is the snippet I use:
ini_set("error_reporting", -1);
ini_set("log_errors", 1);
ini_set("error_log", "/var/www/site/php-error.log");
I assume you are using a Linux distribution, therefore once you have the code in your page, using the command line create the file:
touch /var/www/site/php-error.log
chmod 644 /var/www/site/php-error.log
Then for Ubuntu/Debian do the following:
chown www-data:www-data /var/www/site/php-error.log
Or for Centos/Red Hat:
chown apache:apache /var/www/site/php-error.log
You should then see the errors being logged. If this fails then check the error log by viewing it realtime and then refreshing the page. To view the log in realtime do the following:
For Ubunut/Debian:
tail -f /var/log/apache2/error
For Centos/Red Hat
tail -f /var/log/httpd/error
Upvotes: 2
Reputation: 106
First please check using phpinfo() if your default settings is being overwritten by your htaccess. The phpinfo will show you the local and master values.
Upvotes: 4