Miscellaneouss

How To Enable And Disable PHP Error Logging Using .htaccess File

enable-disable-php-error-logging
mm
Written by Santosh Prasad

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

Thanks:

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