How to Enable WP_DEBUG in WordPress (and Read the Error Log)

If your WooCommerce or WordPress site is acting up – slow pages, broken layouts, or mysterious white screens – you might need a closer look under the hood. That’s where WP_DEBUG comes in.

It’s a simple debugging feature built into WordPress that can help you uncover hidden PHP errors or plugin conflicts. The good news? You don’t need to be a developer to turn it on and start gathering clues.

Let’s walk through how to enable it, where to find the error logs, and what to do once you have them.

What Is WP_DEBUG?

WP_DEBUG is a built-in WordPress setting that turns on error reporting. It helps developers (and site owners!) spot problems with plugins, themes, or custom code.

When enabled, it shows or logs:

  • PHP errors
  • Deprecated functions
  • Notices and warnings
  • Backend issues that could affect performance

But don’t worry, it doesn’t break anything. It just reveals what’s happening behind the scenes.

Step-by-Step: How to Enable WP_DEBUG Safely?

Before you make any changes, make sure your site is backed up or you’re working in a staging environment.

  1. Open your site’s wp-config.php file You’ll find this in the root folder of your WordPress install. You can access it via FTP or your web hosting file manager.
  2. Insert the following code:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );
define( 'SCRIPT_DEBUG', true );

Make sure you place it before this line:

/* That's all, stop editing! Happy blogging. */

This setup logs all PHP issues to a file, but doesn’t show them on your site (which is great for live environments).

Where to Find the Debug Log?

Once you’ve enabled debug logging and reproduced the issue on your site, the errors will be saved to a file here:

/wp-content/debug.log

You can download this file using:

What to Do With the Error Log

When you open the debug.log file, you’ll see messages that look something like:

[03-Apr-2025 10:45:12 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function wc_get_product()

This tells you:

  • The date/time the error happened
  • What the issue is
  • What file it occurred in

If you’re contacting support (like WooCommerce support), send us this file or paste the relevant lines. It helps support agent to pinpoint the issue faster.

Tips for Reading the Log

  • Look for patterns: Are multiple errors pointing to the same plugin or file?
  • Search for plugin or theme names: If an error mentions one, that’s your likely culprit.
  • Keep an eye out for “fatal error” or “undefined function“: These usually stop something from loading.

Don’t Forget to Turn It Off

Once you’ve finished troubleshooting:

  1. Set WP_DEBUG back to false.
  2. Delete the debug.log file if it’s large or no longer needed.
define( 'WP_DEBUG', false );

Bonus: Other Helpful Debugging Options

  • WP_DEBUG_DISPLAY: Show errors on the screen (best for local dev only).
  • SCRIPT_DEBUG: Load unminified CSS/JS for better troubleshooting.
  • SAVEQUERIES: Log database queries (can slow your site—only use temporarily).

Debug Plugins to Consider

For more visual tools:

  • Query Monitor: Shows database queries, hooks, and HTTP requests.
  • Debug Bar: Adds debugging info to your admin bar.

Both plugins work great with WP_DEBUG.

Wrapping Up

If your site’s acting strangely, enabling WP_DEBUG is a smart first move. It’s simple, safe, and gives you real clues, not guesses.

Whether you’re fixing a theme issue or checking why a plugin isn’t behaving, this tool helps you (and us!) get answers faster.

Need help reading the logs or resolving what you find? Drop your message in the comment, and don’t forget to attach your debug log!

References:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may also enjoy…