How do I enable error logging for PHP scripts which helps in debugging application?

PHP errors are by default logged to the web server’s error log file (at least they are with the default setup on most Linux distros) but it is also possible to instead log PHP errors to a file of your choice. This is useful on production websites so you can periodically check for errors and fix them in a location other than the default webserver error log file.

If you do not currently have a php.ini, make one and place it in the same folder(s) as the PHP script(s) that you want to track errors for. You will need to add the following 2 lines:

log_errors = On
error_log = error_log

If we choose to enable error logging, then we MUST check the error_log often and take corrective actions for persistent errors, it’s recommend having it disabled for security reasons.

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.