Error Logging via the HTAccess file

Step 1: Create a log file

Create an empty file called “php-errors.log”. This file will serve as your site’s PHP error log. Your server will need write access to this file, so make sure to set the appropriate permissions. This file may be placed in any directory, but placing it above the web-accessible root directory of your site is advisable for security reasons. Once this file is created, writable, and in place, take note of its absolute directory path and continue to the final step.

Step 2: Add the magic code

Next, open your site’s root .htaccess file and add the following code:

# log php errorsphp_flag display_startup_errors offphp_flag display_errors offphp_flag html_errors offphp_flag log_errors onphp_value error_log /home/path/logs/php-errors.log