# Enable error logging in PHP
Source: https://docs.webgee.com/en/development/how-do-i-enable-error-logging-in-my-php-script



Make PHP record errors so you can see what is failing. Applies to shared,
reseller and Premium hosting.

A blank white page almost always means a fatal error with display disabled.
Logging is how you see it.

<Callout type="error">
  **Never enable `display_errors` on a live site.** Error messages reveal file
  paths, database names and sometimes credentials, and attackers read them
  deliberately. Log to a file instead — the information is identical and only you
  can see it.
</Callout>

## For one script [#for-one-script]

Add at the very top, before any other code:

```php
<?php
ini_set('log_errors', 1);
ini_set('error_log', __DIR__ . '/error_log');
error_reporting(E_ALL);
```

Errors are written to `error_log` beside the script. Read it as described in
[Find your error log](/en/development/how-do-i-find-my-error-log-file-to-find-errors-for-my-php-application).

## For the whole account [#for-the-whole-account]

**cPanel → Select PHP Version → Options**:

| Setting           | Value                    |
| ----------------- | ------------------------ |
| `log_errors`      | `On`                     |
| `error_reporting` | `E_ALL`                  |
| `display_errors`  | **`Off`** — leave it off |

See [Change your PHP version and settings](/en/development/change-php-version).

## WordPress [#wordpress]

Edit `wp-config.php`, above `/* That's all, stop editing! */`:

```php
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
```

Errors go to `wp-content/debug.log`.

`WP_DEBUG_DISPLAY` set to `false` is what keeps them off the page. Enabling
`WP_DEBUG` alone shows errors to visitors — see
[Enable WP\_DEBUG](/en/hosting/wordpress/how-to-view-enable-and-view-errors-on-a-wordpress-installation-wp-debug).

## Debugging on a live site [#debugging-on-a-live-site]

If you must, restrict output to your own IP:

```php
if ( $_SERVER['REMOTE_ADDR'] === '203.0.113.10' ) {
    ini_set( 'display_errors', 1 );
    error_reporting( E_ALL );
}
```

Remove it once finished.

## Turn it off afterwards [#turn-it-off-afterwards]

Verbose logging writes on every request. Leaving `E_ALL` on a busy site produces
a log file large enough to affect your disk quota, and the noise buries anything
real.

## Related [#related]

* [Find your error log](/en/development/how-do-i-find-my-error-log-file-to-find-errors-for-my-php-application)
* [PHP 500 errors and how to resolve them](/en/development/php-500-errors-and-how-to-resolve-them)
