Skip to main content
mySites.guru
Joomla securityUrgent Joomla security release tomorrow, 1 December at 16:00 UTC, for 5.4.x and 6.2.xHow to prepare

WordPress Debug Constants Explained

WordPress Debug Constants Explained

WordPress has a handful of PHP constants that control how errors are reported. They all live in your /wp-config.php file, alongside the hardening constants we check for such as DISALLOW_FILE_EDIT, and most WordPress developers never touch them. That’s usually fine until something breaks and you have no idea why.

But one of these constants has a security problem that most people miss entirely.

Why is WP_DEBUG_LOG a security risk on live sites?

This is the one that catches people out. Setting WP_DEBUG_LOG to true writes PHP errors to /wp-content/debug.log, and that file is publicly accessible by default. Anyone who knows the path can read it. Worse, Google has already indexed thousands of them.

allinurl search for wp-content/debug.log

These log files can expose database credentials, file paths, plugin internals, and other details that make an attacker’s job much easier. If your site has WP_DEBUG_LOG set to true in production, fix it now.

The fix is to pass a custom, hard-to-guess filename instead of true:

define( 'WP_DEBUG_LOG', 'myOwnRandomFileName_as8f6safsif.log' );

Now no one can guess the URL. The log still works, but it’s not sitting at a predictable path waiting to be found.

If you’re worried that your debug log has already been exposed, run a suspect content scan to check for any signs of compromise.

The WordPress debug constants

Here’s what each one does and when to use it. The official docs are at WordPress.org’s Advanced Administration Handbook if you want the full reference.

WP_DEBUG

The main switch. Set it to true and WordPress will show PHP errors, notices, and warnings on screen.

define( 'WP_DEBUG', true );

Leave this on in development, turn it off in production. Simple.

WP_DEBUG_LOG

As covered above, this writes errors to a log file instead of printing them on screen. Useful for production sites where you don’t want visitors seeing PHP warnings, but never set it to true on a live site. Always use a custom filename.

define( 'WP_DEBUG_LOG', 'myOwnRandomFileName_as8f6safsif.log' );

WP_DEBUG_DISPLAY

Controls whether errors show on screen. Set to false on live sites so errors get logged but visitors don’t see them.

define( 'WP_DEBUG_DISPLAY', false );

SCRIPT_DEBUG

Forces WordPress to load the full, unminified versions of its CSS and JS files instead of the minified ones. Handy when you’re debugging front-end issues and need to actually read the source.

define( 'SCRIPT_DEBUG', true );

SAVEQUERIES

Stores every database query in $wpdb->queries so you can inspect them. Good for tracking down slow queries, but leave it off in production because it adds overhead.

define( 'SAVEQUERIES', true );

Checking WordPress debug constants across all your sites

Manually checking wp-config.php on every site gets old fast. The mySites.guru snapshot reads your WordPress config and flags anything that doesn’t match best practice. Most settings have one-click toggles so you can fix them without editing files. The same one-click approach works for other WordPress configuration checks, like removing the WordPress logo from the admin bar, disabling automatic updates, and cleaning up leftover default content.

WordPress configuration constants in a mySites.guru snapshot, from WP_DEBUG to AUTOSAVE_INTERVAL, each with an OK or 1 Issue pill and a switch to change it

You can also view any single constant across all your connected sites at once using the Ultimate Toolset. Click through any snapshot tool to see that value on every site in one view.

The WP_DEBUG_LOG check across all WordPress sites, each marked OK with debug logging off

For a broader look at hardening your WordPress and Joomla installations, see the WordPress and Joomla security guide.

Need someone to fix it for you?

If debugging isn’t your thing, or you’d rather not deal with it, we offer set-fee site fixes at fix.mysites.guru. No hourly billing, no surprises.

Fix your Joomla or WordPress issue today

Can you try mySites.guru free for a month?

We haven’t raised our prices since 2012. But if you want to see the toolset for yourself first, you can use mySites.guru free for a whole month.

First Month Free

Frequently Asked Questions

Why is leaving WP_DEBUG_LOG set to true a security risk on a live site?
It writes errors to /wp-content/debug.log, which is publicly accessible by default and has been indexed by Google on thousands of sites, potentially exposing sensitive server information.
How can I safely use WP_DEBUG_LOG without exposing the log file?
Pass a custom, hard-to-guess filename string instead of true, for example define('WP_DEBUG_LOG', 'myRandomFileName.log'), so the file cannot be found by guessing the default path.
How does mySites.guru help manage WordPress debug constants across many sites?
The mySites.guru snapshot reads each site's wp-config.php, flags constants that do not match best practice, and offers one-click toggles to fix them without manual file editing.
EU icon: AI MODIFIEDWritten and edited by a human, with AI assistance. Our approach to AI

What our users say

Michael Sønderup Nielsen
Michael Sønderup NielsenJoomla Consultant, Joomlakonsulenten
★★★★★

I have been a mySites.guru customer since February 2014, and I now look after more than a hundred Joomla sites through it. Twelve years on, it is still the first place I look whenever something feels off. What makes it work is not just the scanning. It is the judgement built into it. The vulnerable extension alerts do not simply say "update this". They explain what the flaw actually does, whether an attacker needs to log in first, and exactly which version closes it. That is what cracked a case for me recently. The platform pointed out that a critical plugin on a client site was a hidden dependency, installed automatically in the background by another extension. The client had never chosen it and had no idea it was there. Nothing else I use would have told me that. The tools show the same care. Separating "100% certain hacked" from "suspect patterns" is exactly the right distinction, and it stops you frightening a client with a number that turns out to be ordinary software. The "executables only" filter on the core folder check took a list of 250 files down to 13 in a single click. And being able to read a file in the built-in editor before deleting it is a small thing that matters enormously. Then there is Phil. Sharp, quick to respond, and still clearly invested in the details after all these years. That combination is rare. Thank you, Phil. Genuinely.

Read more reviews
Tom Webb
Tom WebbCompany Director at Inlet Technologies
★★★★★

One dashboard for every client site — updates, vulnerable extensions, SSL and uptime, all in one place. What used to be a half-day of logging into admin panels one by one is now a five-minute morning check, and the vulnerability alerting has flagged issues before I'd have spotted them myself. If you look after more than a couple of sites, it pays for itself fast.

Read more reviews

Read all 313 reviews →

Get an email when the next post is published

Ready to Take Control?

One free audit of one site · no card · about 2 minutes to connect

Get Your Free Site Audit