How to Enable WordPress Error Logging for Debugging

Bugs happen. And when they do error reporting is needed to squash them. Here is how to turn it on.

Look for these lines and/or add them to your WordPress
wp-config.php file. This file is located in your WordPress home directory.

// Turn on Debugging
define('WP_DEBUG', TRUE); 

// Yes, log errors please
define( 'WP_DEBUG_LOG', TRUE );

// Let's not show errors on the page.
define( 'WP_DEBUG_DISPLAY', FALSE ); 

Now, when things go bad for WordPress, you can see why by visiting this file:

http://[your-website]/wp-content/debug.log

Now go a step further and turn on PHP Error Reporting. Add this snippet next.

// Turn on Error Reporting
ini_set("log_errors", TRUE);

// Report ALL issues, not just the really bad ones.
error_reporting (E_ALL);

// Let's not show errors on the page.
ini_set ('display_errors', FALSE);

This creates error logs in the folder that they’ve happened in. For WordPress theme and plugin issues, we generally are interested in this file:

http://[your-website]/wp-content/error_log

Your code should look like this…

It’s important to point out that once the bugs are squashed, you probably should turn error reporting off. To do this, simply change each TRUE to FALSE. It’s like flipping a switch.

However, if you’re working on a site that is under development or not generally available to the public, setting the display items to TRUE can make your life a lot easier.

You can’t squash the bugs if you can’t see them.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.