PHP error logging

Overview

When a PHP error occurs, a blank page is displayed rather than the error being shown in the browser. This is the default PHP behaviour, for security reasons: error messages often reveal file paths, database names and other details you do not want published.

The errors are not lost. They are written to a log file on the site:

C:\home\LogFiles\php_errors.log

Note that LogFiles sits alongside your document root, not inside it. Connect by FTP and go up one level from /site/wwwroot to find it.

Below are two configuration changes that may be helpful while you are developing or troubleshooting.

Configure PHP to display errors to the browser

During development, you may want to configure PHP to display errors to the browser.

  1. Create a text file in the website root named .user.ini.
  2. Add the following line to the file:
    display_errors=On
  3. Upload it to the document root of the site (/site/wwwroot).
  4. Restart your application in the Control Panel, as described below.

Configure PHP to not log errors in the log file

The error log can get quite large if there is a known issue with the application. Though we do not recommend it, you can disable error logging.

  1. Create a text file in the website root named .user.ini.
  2. Add the following line to the file:
    log_errors=Off
  3. Upload it to the document root of the site (/site/wwwroot).
  4. Restart your application in the Control Panel, as described below.

Restarting the application

A .user.ini file has no effect until the site is recycled.

  1. Log in to the Everleap Control Panel at cp.everleap.com.
  2. From the top menu click Shared Sites.
  3. On the Shared Cloud Sites Overview page, click Manage next to the applicable site.
  4. On the Site Overview page, find the Site Tools panel.
  5. Click Recycle.
The Site Tools panel on the Site Overview page, showing Site: On with the Stop Site and Recycle buttons

Verify it worked

Upload a phpinfo script and check the Local Value column for the directive you changed. It should show your new value while the Master Value column stays at the server default. See Reviewing and updating PHP settings for how to do this.

Notes

  • Turn display_errors back off before the site goes live. Error output shown in a browser is a common source of information disclosure.
  • If you disable logging with log_errors=Off, remember that you have also removed your own ability to diagnose the problem later.

Related Articles