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 at http://www.suresupport.com/faq/71/468.

To enable PHP error logging, you can add the following directives either to the global php.ini file of your hosting account, or to a php.ini file in the folder where you want error logging enabled:

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

Replace %USER% with the username of your hosting account (your Control Panel username).

The above settings are recommended. You can alter them according to your needs.

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

The line log_errors = On 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/%USER%/private/php-errors.log will set the PHP interpreter to record its errors in the specified file in the private folder on your account. Remember to replace %USER% with the username of your hosting account. If you want, you can choose another folder or a different file to store the logs in.