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 errors php_flag display_startup_errors off php_flag display_errors off php_flag html_errors off php_flag log_errors on php_value error_log /home/path/logs/php-errors.log