WordPress debug.log: Location, Size, and How to Clear It

Find wp-content/debug.log, stop it being public, read a huge log without crashing your editor, and clear it safely from the WordPress dashboard.

Updated Oct 24, 2026 7 min read
On this page
  1. The short answer
  2. Too big to open?
  3. Where is debug.log?
  4. No debug.log at all?
  5. Is your debug.log public? How to block it
  6. Apache: block it in .htaccess
  7. Nginx: block it in the server block
  8. Or move the log outside the web root
  9. Why debug.log gets so large
  10. Read a huge debug.log without opening all of it
  11. From the WordPress dashboard
  12. Over SSH, with any file size
  13. Find the error that matters
  14. How to clear debug.log safely
  15. Stop it from growing back
  16. FAQ
  17. Official sources

The short answer

debug.log lives in wp-content unless WP_DEBUG_LOG points to another path, and it only exists while WP_DEBUG and WP_DEBUG_LOG are on. Check which applies in Tools > Site Health > Info.

Too big to open?

Read only the newest entries, from the dashboard or with tail over SSH, save a copy outside the web root, then empty the file and see which errors come back.

WordPress writes its error log to wp-content/debug.log by default, but only while WP_DEBUG and WP_DEBUG_LOG are both turned on. If that file has grown too large to open, read only its newest entries, block it from the public, save a copy, and then clear it: this guide shows each step, from the dashboard or over SSH.

Where is debug.log?

With define( 'WP_DEBUG_LOG', true ); in wp-config.php, WordPress logs to debug.log inside the content directory (WP_CONTENT_DIR). On most sites that is /wp-content/debug.log, next to the plugins and themes folders.

Since WordPress 5.1, WP_DEBUG_LOG can also hold a file path. In that case the log is wherever the path points, and there is no debug.log in wp-content.

To check without opening any file, go to Tools → Site Health → Info and open WordPress Constants. WP_DEBUG_LOG shows Enabled (default location), a path (custom location) or Disabled. WP_CONTENT_DIR shows the folder the default log goes to.

No debug.log at all?

WP_DEBUG_LOG does nothing unless WP_DEBUG is true. Add these lines to wp-config.php above the line that says “stop editing”:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

The file is created with the first error, so a site with no errors has no log yet. Write false without quotes when you turn it off: 'false' in quotes is a string, and WordPress reads it as true.

Is your debug.log public? How to block it

If the log sits in wp-content, anyone who requests https://your-site.com/wp-content/debug.log may be able to download it, unless your server blocks it. The address is the same on every WordPress site, so it is easy to look for. The log can contain server paths, plugin and theme names, and the full text of failed database queries.

Test it: open that address in a private browser window. If you see log lines, the file is public. A 403 means it is blocked; a 404 means the file is not there (or your server hides it).

WordPress warns you too. When WP_DEBUG and WP_DEBUG_LOG are on and errors are not displayed to visitors, Site Health shows “Your site is set to log errors to a potentially public file”, as a critical issue when the log is inside the WordPress folder. Security scanners such as Wordfence report it as “Publicly accessible config, backup, or log file found”.

Apache: block it in .htaccess

On Apache (or a host that reads .htaccess files), add this to the .htaccess file in your WordPress root, outside the # BEGIN WordPress block so WordPress never overwrites it:

# Deny web access to the WordPress debug log
<Files "debug.log">
    Require all denied
</Files>

Nginx: block it in the server block

Nginx ignores .htaccess. Add this inside your site’s server { } block, then reload Nginx (adjust the path if WordPress lives in a subfolder):

# Deny web access to the WordPress debug log
location = /wp-content/debug.log {
    deny all;
}

Test the address again in a private window: you should now get 403 Forbidden.

Or move the log outside the web root

The safest place for a log is a folder the web server does not serve at all. Set WP_DEBUG_LOG to a full path in a folder PHP can write to:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', '/home/example/logs/wp-debug.log' );
define( 'WP_DEBUG_DISPLAY', false );

One trade-off: dashboard viewers that read wp-content/debug.log, including Quick debug.log Viewer, will not see a log you moved. You then read it over SSH, as shown below.

Why debug.log gets so large

Every PHP warning, notice and deprecation message is appended as a new entry, on every request that triggers it. One outdated plugin that raises a notice on each page load adds lines with every visit, bot and cron run. Nothing in WordPress trims or rotates the file, so it grows until someone clears it.

So a huge log is a symptom: some code keeps raising the same messages. Clearing the file frees space; fixing those messages stops the growth.

Read a huge debug.log without opening all of it

You rarely need the whole file. The error behind today’s problem is near the end, because new entries are appended at the bottom.

From the WordPress dashboard

Quick debug.log Viewer is a free plugin that shows wp-content/debug.log in its own admin menu, Quick debug.log Viewer, newest entries first. It groups each error with its stack trace, colours entries by type, and works even after you turn WP_DEBUG off, as long as the file still exists. Administrators also get a floating button on the front end that opens the same viewer.

Know its limits before you rely on it with a very large file:

  • It shows the newest 300 entries, and Load More adds 30 at a time, all taken from the last 5,000 lines of the file.
  • It reads the whole file into PHP memory first, so a log of hundreds of megabytes can hit your memory limit. Clear or trim such a file over SSH first.
  • It only reads the default wp-content/debug.log, not a custom WP_DEBUG_LOG path.

Over SSH, with any file size

Command-line tools read the file in a stream, so size does not matter. From your WordPress root:

# How big is it?
ls -lh wp-content/debug.log

# The last 200 lines
tail -n 200 wp-content/debug.log

# The last 20 fatal errors, with line numbers
grep -n "PHP Fatal error" wp-content/debug.log | tail -n 20

# Watch new entries arrive while you reload the broken page
tail -f wp-content/debug.log

To open it on your computer, download it by SFTP and use an editor that copes with large files, or split off only the end with tail -n 5000 wp-content/debug.log > ~/debug-tail.log and download that.

Find the error that matters

Entries start with a timestamp in square brackets (in UTC, because WordPress sets PHP’s time zone to UTC). PHP’s own messages then name their type: PHP Fatal error, PHP Warning, PHP Notice or PHP Deprecated. Work in this order:

  1. Fatal errors first. They stop the request and cause blank pages and the “There has been a critical error on this website” message. In Quick debug.log Viewer, click the Fatal filter.
  2. Match the time. Compare the timestamp with when the problem happened, converted to UTC.
  3. Read the file path. A path such as wp-content/plugins/plugin-name/… tells you which plugin or theme raised it. Type the folder name in the viewer’s search box to see only its entries. The search covers the newest 300 entries; for older history, use grep.
  4. Then the noise. Warnings and deprecation messages that repeat thousands of times are what makes the file huge. Update or replace the code behind them.
Quick debug.log Viewer in the WordPress admin, filtered to fatal errors with a full stack trace, with the Search log box (1), the Filter logs buttons with Fatal active (2) and the Clear debug.log and Download debug.log buttons (3) highlighted
Search the log (1), filter to fatal errors first (2), then download a copy and clear the log (3). Example data.

How to clear debug.log safely

Deleting or emptying the file is safe for WordPress: PHP writes a new entry, and creates the file again if needed, at the next error. What you can lose is the evidence. Follow this order:

  1. Save a copy. Click Download debug.log in Quick debug.log Viewer, or over SSH compress it outside the web root: gzip -c wp-content/debug.log > ~/debug-$(date +%F).log.gz. Don’t leave copies inside wp-content, where they can be public too.
  2. Clear it. Click Clear debug.log and confirm, or run truncate -s 0 wp-content/debug.log. Both empty the file instead of deleting it.
  3. Reproduce the problem. Load the broken page, submit the form, or run the action that fails.
  4. Read what comes back. The entries that appear within minutes are your active issues. A short, fresh log is also what plugin support teams ask for.

Stop it from growing back

  • Fix the repeat offenders. Update the plugin or theme named in the most frequent entries, or report it to its developer with your fresh log.
  • Turn logging off when you are done. Set WP_DEBUG to false on the live site. The WordPress documentation does not recommend debug mode on live sites.
  • Never show errors to visitors. Keep WP_DEBUG_DISPLAY false whenever WP_DEBUG is on.
  • If you need a permanent log, keep it outside the web root and ask your host about log rotation, so old entries are compressed and removed automatically.

Your own code can write to the same file: anything passed to PHP’s error_log() lands in debug.log while logging is on. That is how the checks in wp_mail Attachments Not Working: Paths, URLs and wp_mail_failed report a missing file. For the other tools worth keeping on a client site, see WordPress Plugins for Developers: Debug & Staging Tools.

What Quick debug.log Viewer does

  • Shows wp-content/debug.log in the dashboard, newest entries first
  • Filters by Fatal, Warning or Notice and searches recent entries
  • Keeps each stack trace together in one entry
  • Downloads a copy, and clears the file after a confirmation
  • Works even after WP_DEBUG is off, as long as the file exists
Get Quick debug.log Viewer

FAQ

Where is the WordPress debug.log file?

By default it is wp-content/debug.log, inside the content directory. Since WordPress 5.1 WP_DEBUG_LOG can be set to a file path instead, and then the log is wherever that path points. Tools > Site Health > Info > WordPress Constants shows which applies on your site.

Why is there no debug.log in wp-content?

WordPress only writes it when both WP_DEBUG and WP_DEBUG_LOG are true in wp-config.php, and only after the first error. If WP_DEBUG_LOG is set to a path, the file is at that path instead.

Is wp-content/debug.log publicly accessible?

It can be: unless your server blocks it, anyone who opens your-site.com/wp-content/debug.log can download it. Block it with a Files rule in .htaccess on Apache or a location rule with deny all on Nginx, or move the log outside the web root.

Can I delete or empty debug.log?

Yes. WordPress keeps working and PHP starts writing again at the next error. Download a copy first if you are still investigating, because emptying the file removes the only record of past errors.

Why does debug.log keep growing back?

Because the code that raises the errors is still running. Clearing removes the history, not the cause. Fix or update the plugin or theme behind the most frequent entries, and set WP_DEBUG to false when you finish debugging.

Official sources

Related guides