Skip to content
Aaron Carmen
Errors and fixes

How to Log WordPress Errors Safely with the Debug Log

By Aaron CarmenUpdated October 19, 20264 min readTested on WordPress 7.1.3, October 19, 2026

Quick answer

To log WordPress errors safely on a live site, set WP_DEBUG and WP_DEBUG_LOG to true and WP_DEBUG_DISPLAY to false in wp-config.php. Errors then go to wp-content/debug.log instead of the page. Better still, point WP_DEBUG_LOG at a file outside your public folder, because the default debug.log can be opened by anyone who guesses the address.

What you see

  • Something on the site stopped working, but there's no error message
  • A plugin's support team asked for your error log
  • Warnings or file paths are showing at the top of your pages
On this page
  1. Why not just turn on WP_DEBUG?
  2. The settings
  3. Reading the log
  4. Keep the log private
  5. Don’t leave it on for months

To log WordPress errors safely, you want them written to a file you can read, not printed on pages your visitors see. WordPress does this with three settings in wp-config.php. I tested them on WordPress 7.1.3 with PHP 8.3, with debug off, with the recommended settings, and with the log kept outside the public folder.

Why not just turn on WP_DEBUG?

Because on many hosts, errors then show up on the page. With WordPress’s default settings on my test site, a small PHP warning was printed at the top of every page that triggered it, server path and all:

A WordPress site with a PHP warning printed above the header showing the file path on the server
With display on, a warning appeared at the top of the page for every visitor.

Whether you see this depends on your host’s PHP setting display_errors. PHP’s recommended production settings turn it off, but not every host follows them. The settings below make WordPress hide errors from the page either way.

The settings

Open wp-config.php in your site’s main folder and find the line define( 'WP_DEBUG', false );. Replace it with:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

What each one does:

  • WP_DEBUG is the main switch. With it off, WordPress doesn’t report deprecation notices at all. On my test site, a deprecated function call left no trace until this was on.
  • WP_DEBUG_LOG writes errors to wp-content/debug.log.
  • WP_DEBUG_DISPLAY set to false keeps errors off the page. With these three settings, the same warning that appeared in the screenshot went only to the log.

Then load the page where the problem happens, and open wp-content/debug.log.

Reading the log

These are three real lines from my test site, one of each kind you’ll see most:

[19-Oct-2026 14:33:11 UTC] PHP Warning:  Undefined array key "email" in /wordpress/wp-content/mu-plugins/lab-debug.php on line 6
[19-Oct-2026 14:33:13 UTC] PHP Deprecated:  Function lab_old_contact_form is <strong>deprecated</strong> since version 7.0.0! Use lab_contact_form instead. in /wordpress/wp-includes/functions.php on line 6260
[19-Oct-2026 14:33:14 UTC] Lab Contact Widget: form sent to office@example.com

Every line follows the same pattern: the time in UTC, the type, the message, then the file and line number.

  • PHP Warning: something went wrong but the page still loaded. Here, code asked for an “email” setting that didn’t exist. Warnings often explain features that quietly stopped working.
  • PHP Deprecated: code is using something WordPress or PHP plans to remove. It works today and may break after a future update. The <strong> tags are really in the file, because WordPress writes this message as HTML.
  • A line with no “PHP” label was written on purpose by a plugin, with PHP’s error_log() function. These are notes, not errors.
  • PHP Fatal error lines are the ones that break a page completely. My guide to the WordPress white screen of death covers those.

To find the culprit, look at the folder after wp-content. plugins/ plus a name points to that plugin, and themes/ plus a name points to a theme. A path in wp-includes, as in the deprecated line, is where WordPress noticed the problem, not where it came from. Search the rest of the log for the function name to find which plugin called it.

Keep the log private

On my test site, anyone could open /wp-content/debug.log in a browser and read the whole file. Some hosts block that. Don’t assume yours does. The log holds your server’s file paths, and plugins can write anything into it. The note in my test included an email address.

Since WordPress 5.1, WP_DEBUG_LOG can be a file path instead of true. Point it at a folder outside your public folder:

define( 'WP_DEBUG_LOG', '/home/youraccount/logs/wp-errors.log' );

Use your own path. Your host’s file manager shows the full path to public_html, and the folder above it is usually yours but not public. Create the logs folder first. On my test site, with the log pointed outside the public folder, errors went to that file, no debug.log appeared in wp-content, and /wp-content/debug.log returned a 404.

Don’t leave it on for months

The log grows with every page view that hits the same problem. On my test site, 58 page views with one warning each added 58 lines of 129 bytes. At 1,000 page views a day that’s about 4 MB a month, and a plugin throwing ten warnings a page makes it about 40 MB. FreshySites describes a PHP error log that had reached 39 GB before anyone noticed.

When you’ve found the problem:

  1. Set WP_DEBUG back to false, or remove the three lines.
  2. Delete the log file.
  3. Fix or replace whatever was filling it.

Regular warnings in a log often mean a plugin is falling behind on updates. Checking logs and catching that early is part of my WordPress development work. If the site is slow rather than erroring, see how to speed up a WordPress site.

FAQ

Common questions

Where is the WordPress debug log?

By default it's wp-content/debug.log, created the first time an error is logged after you turn logging on. If WP_DEBUG_LOG is set to a file path instead of true, the log is written to that file. If there's no file at all, nothing has been logged yet, or logging isn't switched on.

Is it safe to leave the debug log on?

For a few days while you track a problem, yes, as long as WP_DEBUG_DISPLAY is false and the log is somewhere private. Don't leave it on for months: the file keeps growing with every repeated warning, and it can hold file paths and data that plugins write to it.

What's the difference between WP_DEBUG and WP_DEBUG_LOG?

WP_DEBUG is the main switch. It makes WordPress report every kind of PHP error, including deprecation notices. WP_DEBUG_LOG decides whether those errors are written to a file, and WP_DEBUG_DISPLAY decides whether they're printed on the page. The other two do nothing unless WP_DEBUG is true.

Why is my debug.log empty?

Either nothing has gone wrong since you turned it on, or the page with the problem hasn't been loaded yet. Visit the page that misbehaves, then check again. If a typo in wp-config.php itself is the problem, WordPress fails before it reads the logging settings, so check your host's PHP error log instead.

Can I delete debug.log?

Yes. WordPress creates a new one the next time it logs an error. Delete it when you've finished troubleshooting, and before you send a site to anyone else.

Aaron Carmen, SEO specialist

About the author

Aaron Carmen

Senior WordPress Developer and SEO Specialist

I've built and optimized WordPress websites since 2013, 13+ years in total, including 9.5 years building WordPress sites for every client of a dental marketing agency. Today I help local businesses and agencies with WordPress development and SEO, so they get found on Google Search, Google Maps and AI search.

WordPress is a trademark of the WordPress Foundation. Aaron Carmen is not affiliated with or endorsed by the WordPress Foundation or the WordPress open source project.

Contact

Want this done for you?

Tell me about your site and what you need. I'll reply within one business day with any questions, then a fixed quote.

  • Reply within one business day
  • No obligation, no hard sell
  • Form and email only, calls optional
What you need

Prefer email? hello@aaroncarmen.com