Checking wp debug.log files
Why debug.log Files Matter
- Performance impact: Large log files can eat up disk space and slow down file operations.
- Backup bloat: If your backups include
debug.log, they can become unnecessarily large. - Security risk: Debug logs may contain sensitive paths, plugin names, or even database queries. If exposed publicly, attackers could use this information.
- Maintenance signal: A growing
debug.logoften indicates unresolved errors or misconfigured plugins/themes.
Finding the Biggest debug.log Files
On a Linux server, you can use the find command to locate and measure log files. Here are two approaches:
1. Broad Search Across All Home Directories
find /home/ -type f -name "debug.log" -exec du -h {} + | sort -hr | head -20
- What it does: Searches every user’s home directory for
debug.logfiles. - Why use it: Useful if you’re not sure where WordPress is installed or if you manage multiple accounts.
- Output: Shows the top 20 largest
debug.logfiles, sorted by size.
2. Targeted Search in WordPress wp-content Folders
find /home/*/public_html/wp-content/ -type f -name "debug.log" -exec du -h {} + | sort -hr | head -20
- What it does: Focuses only on the typical WordPress
wp-contentdirectory under each user’spublic_html. - Why use it: Faster and more precise if you know all your WordPress installs follow the standard cPanel-style layout.
- Caveat: Not all WordPress sites use
/public_html/wp-content/. Some may be installed in subdirectories (/home/user/blog/wp-content/) or custom paths. Adjust the command accordingly.
What to Do After Finding Large Logs
- Inspect the contents: Look for recurring errors. They may point to a misbehaving plugin, theme, or custom code.
- Fix the root cause: Don’t just delete the log — resolve the error generating it.
- Truncate safely: If the file is huge, you can clear it without deleting:
truncate -s 0