How to turn on WordPress debugging safely

Use WP_DEBUG, WP_DEBUG_LOG and WP_DEBUG_DISPLAY to see WordPress errors without showing them to visitors, and turn debugging off afterwards.

How-to guideIntermediate2 min readUpdated

WordPress can log every PHP error, warning and notice to a file. It’s the quickest way to diagnose plugin and theme problems.

Turn on logging (not display)

In wp-config.php, find define('WP_DEBUG', false); and replace it with:

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

Errors are now written to wp-content/debug.log and not shown to visitors.

Read the log

  1. Reproduce the problem.
  2. Open wp-content/debug.log in System Info & Files then File Manager.
  3. Read from the bottom up. Fatal errors matter most; deprecation notices are usually harmless.

Turn it off afterwards

Set WP_DEBUG back to false, and delete debug.log. Left on, the log grows endlessly and can reveal file paths and details to anyone who finds it.

Keep the log private

If you’ll leave logging on for a while, move the log outside the web root:

define('WP_DEBUG_LOG', '/home/USERNAME/wp-debug.log');

Replace USERNAME with your DirectAdmin username.

Everything in this guide works on Traxio’s WordPress hosting: 30 days free, then £0.99 a month.

Popular

Tip: press / to search from any pageSee all results