WordPress

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

· Updated Apr 3, 2025 · 4 min read

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:

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).

Enable WP_DEBUG Safely

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:

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

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

Debug Plugins to Consider

For more visual tools:

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:

Shameem Reza
Written by Shameem Reza

I am a Happiness Engineer at Automattic, helping merchants turn WooCommerce chaos into calm with clear solutions and simple technical breakdowns.

Enjoyed reading this?

This site stays ad-free and independent. If something here saved you time or taught you something new, a coffee goes a long way.

Buy me a coffee ☕
Keep reading