Web Development

Enable PHP Error logging using htaccess

Normally error reporting and display errors are set to off on productstion mode, so its hard for developers to find the error which are occurring.

So we can set the PHP.ini values using htaccess also, Below are some rules which can be defined in htaccess file and it will log the all php errors for review.

[cc lang=”php”]
####### PHP DEBUGGING RULES #######
# supress display of php errors, Below three lines will disable the PHP error reporting to user
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off

# enable verbose PHP error logging to a file, Below three lines will log the all PHP error, warning and notices in log files at the path specified.
php_flag log_errors on
php_value error_reporting 2047
php_value error_log /home/domain.com/php.error.log
####### END PHP DEBUGGING RULES #######
[/cc]

Hope you find this trick helpful. Let us know your suggestion/comments on this.

Shares:
  • […] the original post here: Enable PHP Error logging using htaccess | Xpert Developer Bookmark to: This entry was posted in Uncategorized and tagged its-hard, php, rules-which, […]

    Reply
  • Richard
    Richard
    May 5, 2011 at 9:12 pm

    Does this assume that the program being logged doesn’t itself set the values of the ini error values?

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *