Wednesday, March 5, 2008

Enable PHP Error Logging

How to Enable PHP Error Logging

To enable error logging edit the /etc/php.ini file and locate the error_log and uncomment it by removing the semi-colon. Next put in the filename of where the errors and warnings should be logged to. Example:

error_log = /var/log/php_error

On production sites it is advisable to have the following options set:

error_reporting = E_ALL
display_errors = Off
display_startup_errors = Off
log_errors = On

This way the errors are logged to a file instead of being displayed on the website. If you prefer to change this, then switch to display_errors = On. Please visit http://us.php.net/manual/en/ref.errorfunc.php to see the error handling and logging section in the php manual for extensive details. Make sure to restart your webserver after making changes to the /etc/php.ini file.

No comments: