WEB HOSTING SUPPORT NETWORK
     
 

Enabling PHP error logging

You can enable PHP error logging for your scripts by changing the PHP settings for your account. Details on how to do this can be found in our Changing PHP settings article.

To enable PHP error logging, you should add the following directives to a PHP configuration file (php.ini) in your hosting account:

error_reporting = E_ALL | E_STRICT
log_errors = On
display_errors = Off
error_log = /home/USERNAME/private/php-errors.log

Replace USERNAME with your actual hosting account username (you can find your username listed in the upper left corner of your Control Panel).

The above settings are recommended, and you can alter them according to your needs.

The error_reporting directive defines which errors are to be recorded. The E_ALL constant specifies that all errors and warnings should be logged, and the E_STRICT constant instructs the PHP interpreter to suggest code changes that will make sure the PHP code is compatible with future versions of PHP. You can check all error_reporting predefined constants here:
https://php.net/manual/en/errorfunc.constants.php

The log_errors = On line enables recording of errors in the log file on the server. If this runtime option is set to Off, no errors will be recorded in the log file.

display_errors = Off disables error displaying in the browser. If you set this option to On, then errors will be displayed in the browser when the PHP script is executed.

The line error_log = /home/USERNAME/private/php-errors.log will set the PHP interpreter to record its errors in the specified file in the Private directory on your account. Remember to replace USERNAME with the actual username of your hosting account. If you want, you can choose another folder or a different file to store the logs in.