WordPress debug.log grows continuously on active sites. Without management, a verbose site can accumulate hundreds of megabytes of log data, consuming disk space and making the log harder to navigate. WP Debug Toolkit (WPDT) provides automatic and manual cleanup to keep log files at a manageable size.
WPDT schedules a daily cleanup task via WordPress cron (dbtk_daily_log_cleanup action). On each run, the task checks the error log age and size, then applies the configured cleanup method.
Cleanup runs when either condition is met:
Configure the cleanup method at Settings > Log Cleanup. Three methods are available:
Removes the entire debug.log file and creates a new empty one. No historical data is preserved. This is the most aggressive option and frees the most disk space.
Moves the current log file to a timestamped archive file (e.g., debug.log.old.2026-03-15), then creates a new empty debug.log. Archives are kept for a configurable number of days before being deleted automatically.
Use Archive when you need to preserve historical log data for later reference.
Keeps the most recent portion of the log file and removes the rest. The amount to keep is configurable (in MB). A truncation marker is inserted at the top of the file to indicate that older content was removed.
Use Truncate when you want to maintain a rolling window of recent errors without creating separate archive files.
Three options for immediate cleanup:
Go to Settings > Log Cleanup and click the manual cleanup button. This runs the same cleanup logic as the daily cron, using your current settings.
Press Shift+R in the error log viewer. A confirmation dialog appears. Press Enter to confirm. This deletes the entire log file regardless of the configured cleanup method.
wp dbtk log clear
This clears the debug log from the command line.
Query log files are stored separately from the error log, in wp-content/uploads/debug-toolkit/queries/ as monthly .log text files (e.g., queries-2026-03.log). Query log cleanup has its own retention setting and runs as part of the same daily cron task.
Query log cleanup uses a two-phase approach:
All settings are accessible at Settings > Log Cleanup.
| Setting | Description | Default |
|---|---|---|
| Error log retention | Days before the error log triggers age-based cleanup. Set to 0 to disable age-based cleanup. | 30 days |
| Query log retention | Days before query log files are removed. Set to 0 to disable. | 30 days |
| Max log size | Error log file size (MB) that triggers immediate truncation, regardless of age. | 50 MB |
| Query log max size | Total size (MB) for all query log files combined. | 100 MB |
| Cleanup method | How old error logs are handled: Delete, Archive, or Truncate. | Archive |
| Archive retention | Days to keep archived log files before deleting them. Only applies when cleanup method is Archive. | 90 days |
| Truncate keep size | Amount of recent data (MB) to preserve when truncating. Only applies when cleanup method is Truncate. | 10 MB |
Note: Setting retention to 0 days disables age-based cleanup for that log type. Size-based limits still apply.
The dbtk_daily_log_cleanup action relies on WordPress cron, which is triggered by site visitors. On low-traffic sites, cron events may run late. If reliable scheduling is important, configure a system-level cron job to trigger WordPress cron:
# Run WordPress cron every hour via system crontab
0 * * * * cd /path/to/wordpress && wp cron event run --due-now