In this article I will describe how to configure PHP error logging with log_errors and error_log directives in .htaccess file.
I assume that you have already set up a custom .htaccess file. Please setup a custom .htaccess file if you have not setup it.
Enabling Error Logging
To enable error logging you can use the log_error and error_log directives to setup PHP error logging. Follow the below steps to do this:
1. Loging to your server using SSH.
2. Open the .htaccess file in any text editor to add the following line. Replace path with the path to the log file, and replace filename with the log filename.
# vim .htaccess ... php_flag log_errors On php_value error_log /path/filename ...
3. Save and close the .htaccess file.
4. Verify that new setting is active or not, you will need to create a PHP test file that the contains the following code in the same directory where .htaccess file is located.
# vim phpinfo.php <?php phpinfo(); ?>
Save and close file.
5. Load the test file in your web browser, and then search for the name of the directive. The Local Value column should display the new setting that you specified in the .htaccess file.
Disabling Error Logging
To disable error logging, you will need to modify the log_error line in .htaccess file like below:
php_flag log_errors Off