Miscellaneouss

Debug: “.htaccess error log” or enable & disable PHP Error Logging Using .htaccess File

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.

If your .httaccess file rules are not working follow my this tutorial : How to debug if .htaccess file rules are not working?

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

Thanks:

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment