Guard Dog includes a comprehensive debug logging system to help troubleshoot issues and monitor plugin behavior.
Overview
The debug system provides:
- ✅ Multiple log levels (ERROR, WARNING, INFO, DEBUG)
- ✅ Component-specific logging
- ✅ Structured log output
- ✅ Writes to WordPress debug.log
- ✅ Privacy-safe logging (no passwords)
- ✅ Integration with WordPress debug system
Enabling Debug Logging
Prerequisites
Guard Dog writes to the WordPress debug log. Ensure WordPress debugging is enabled:
In wp-config.php, add or verify:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false); // Don't display errors on screen
This creates the /wp-content/debug.log file that Guard Dog will write to.
Step 1: Access Debug Settings
Navigate to Guard Dog → Settings → Debug Settings
Step 2: Enable Logging
- Check “Enable Debug Logging”
- Choose your Debug Level
- Click Save Changes
Guard Dog will now write debug entries to /wp-content/debug.log alongside WordPress core and other plugin logs.
Debug Levels
ERROR (Recommended for Production)
What it logs: Only critical errors that prevent features from working
Examples:
- Database connection failures
- CAPTCHA verification errors
- Failed external API calls
- Missing required settings
Use when: Running in production, want minimal logging
Log volume: Very low
WARNING (Recommended for Monitoring)
What it logs: Errors + potential issues that don’t break functionality
Examples:
- Deprecated function usage
- Configuration issues
- Missing optional settings
- Unusual behavior
Use when: Monitoring production site for issues
Log volume: Low
INFO (Recommended for Troubleshooting)
What it logs: Errors + Warnings + general operational information
Examples:
- Login attempts
- Lockout events
- 2FA verification
- Access control decisions
- Feature activation
Use when: Investigating specific issue, understanding flow
Log volume: Medium
DEBUG (Recommended for Development Only)
What it logs: Everything – complete detailed execution flow
Examples:
- Function entry/exit
- Variable values
- Query parameters
- API request/response details
- Internal state changes
Use when: Deep troubleshooting, development, finding bugs
Log volume: Very high
Reading Debug Logs
Log Format
Guard Dog entries in the debug.log follow this format:
[Timestamp] Guard Dog - LEVEL [Component] Message
Context data (if any)
Example:
[2024-10-23 14:30:15] Guard Dog - ERROR [CAPTCHA] reCAPTCHA verification failed
IP: 203.0.113.50
Response: invalid-input-secret
The “Guard Dog” prefix helps identify Guard Dog entries in the shared debug.log file.
Log Components
Timestamp: When event occurred (WordPress timezone)
Level: ERROR, WARNING, INFO, or DEBUG
Component: Which Guard Dog feature:
[Login URL]– Custom login URL[CAPTCHA]– CAPTCHA verification[2FA]– Two-factor authentication[Login Limiting]– Login attempt limiting[Access Control]– IP/username blocking[Activity Log]– Activity logging[Temp Access]– Temporary user access[Email Provider]– Email sending[Core]– Core plugin functionality
Message: Human-readable description
Context: Additional relevant data (IP addresses, usernames, details)
Viewing Logs
In WordPress Admin
- Go to Guard Dog → Settings → Debug Settings
- Scroll to Debug Log Viewer
- Guard Dog entries are displayed (filtered from the full debug.log)
- Logs are displayed in reverse chronological order (newest first)
Note: The WordPress debug.log file contains entries from WordPress core, Guard Dog, and other plugins. The Debug Log Viewer automatically filters to show only Guard Dog entries.
Filtering Logs
By Level:
- Select level from dropdown
- Shows only that level and above
By Component:
- Select component from dropdown
- Shows only logs from that feature
By Date:
- Enter date range
- Shows logs from that period
By Search:
- Enter search term
- Searches in message and context
Accessing Logs
Via WordPress Admin:
- Go to Guard Dog → Settings → Debug Settings
- View logs in the Debug Log Viewer
Via FTP/File Manager:
- Access your site files
- Navigate to
/wp-content/debug.log - Download the file for offline analysis
Use for:
- Sharing with support
- Offline analysis
- Archival before clearing
Common Scenarios
Scenario 1: Troubleshooting Login Issues
Enable:
- Debug Level: INFO
- Component: All
Reproduce:
- Try to log in
- Check debug log
- Look for entries with
[Login Limiting],[Access Control],[CAPTCHA],[2FA]
What to look for:
[2024-10-23 14:30:15] Guard Dog - INFO [Access Control] Checking IP: 203.0.113.50
[2024-10-23 14:30:15] Guard Dog - INFO [Access Control] IP is blacklisted, blocking login
Scenario 2: CAPTCHA Not Working
Enable:
- Debug Level: DEBUG
- Component: CAPTCHA
Reproduce:
- Access login page
- Complete CAPTCHA
- Submit form
- Check debug log
What to look for:
[2024-10-23 14:30:15] Guard Dog - DEBUG [CAPTCHA] Sending verification request to reCAPTCHA
Request data: {...}
[2024-10-23 14:30:16] Guard Dog - ERROR [CAPTCHA] Verification failed
Response: invalid-input-secret
Scenario 3: 2FA Codes Not Working
Enable:
- Debug Level: DEBUG
- Component: 2FA
Reproduce:
- Log in with username/password
- Enter 2FA code
- Check debug log
What to look for:
[2024-10-23 14:30:15] Guard Dog - DEBUG [2FA] Verifying TOTP code for user: john
[2024-10-23 14:30:15] Guard Dog - DEBUG [2FA] Expected code: 123456, Provided code: 654321
[2024-10-23 14:30:15] Guard Dog - WARNING [2FA] Code mismatch, verification failed
Scenario 4: Email Not Sending
Enable:
- Debug Level: DEBUG
- Component: Email Provider
Reproduce:
- Trigger email 2FA
- Check debug log
What to look for:
[2024-10-23 14:30:15] Guard Dog - DEBUG [Email Provider] Sending email via Resend
To: [email protected]
[2024-10-23 14:30:16] Guard Dog - ERROR [Email Provider] API request failed
Status code: 403
Response: Forbidden - Invalid API key
Scenario 5: Lockouts Not Working
Enable:
- Debug Level: INFO
- Component: Login Limiting
Reproduce:
- Make failed login attempts
- Check debug log after each attempt
What to look for:
[2024-10-23 14:30:15] Guard Dog - INFO [Login Limiting] Failed login recorded
IP: 203.0.113.50, Attempts: 1/5
[2024-10-23 14:30:20] Guard Dog - INFO [Login Limiting] Failed login recorded
IP: 203.0.113.50, Attempts: 2/5
...
[2024-10-23 14:31:00] Guard Dog - INFO [Login Limiting] Lockout initiated
IP: 203.0.113.50, Expiry: 2024-10-23 14:46:00
Privacy & Security
What IS Logged
✅ IP addresses
✅ Usernames (attempted logins)
✅ Timestamps
✅ Feature decisions (allow/block)
✅ Error messages
✅ Configuration values
✅ API responses (sanitized)
What is NOT Logged
❌ Passwords (never logged)
❌ 2FA codes (not stored)
❌ Recovery codes (not stored)
❌ API secret keys (redacted)
❌ Sensitive post/page content
❌ Payment information
Security Considerations
Log file location:
- Stored in
/wp-content/debug.log - Standard WordPress debug log location
- Should be protected by .htaccess or server configuration
- Not publicly accessible by default
Sensitive data:
- API keys are redacted:
sk-xxx...xxx(first/last 3 chars only) - Tokens are truncated:
abc123...xyz789 - Email addresses may be logged (for debugging email issues)
Access control:
- Only administrators can view logs in WordPress admin
- Debug log file accessible via FTP/server access
- Clear logs to remove sensitive data
Log Management
Log File Size
Logs can grow large with DEBUG level:
Typical sizes:
- ERROR level: 1-5 MB/month
- WARNING level: 5-20 MB/month
- INFO level: 20-100 MB/month
- DEBUG level: 100-500 MB/month (high traffic)
Guard Dog writes to the standard WordPress debug log:
Log File Management
- Location:
/wp-content/debug.log - Shared: Same file used by WordPress core and other plugins
- Growth: Can grow large over time
- Management: Clear periodically to manage size
Clearing Logs
- Go to Debug Settings
- Click “Clear Debug Log”
- Confirm deletion
- All debug logs are deleted
When to clear:
- After downloading for analysis
- Logs growing too large
- Finished troubleshooting
- Before sharing site backup
Disabling Logging
- Go to Debug Settings
- Uncheck “Enable Debug Logging”
- Click Save Changes
Important: Disable DEBUG level on production sites after troubleshooting to avoid performance impact and excessive disk usage.
Sharing Logs for Support
When requesting support:
- Enable appropriate log level:
- Start with INFO
- Increase to DEBUG if requested
- Reproduce the issue:
- Clear existing logs
- Perform the action that causes the issue
- Issue should now be logged
- Access the log:
- Via FTP/File Manager: Download
/wp-content/debug.log - Via WordPress admin: Copy relevant entries from Debug Log Viewer
- Filter Guard Dog entries:
- Search for “Guard Dog” in the log file
- Extract only Guard Dog-related lines
- The log may contain entries from other plugins/WordPress
- Sanitize if needed:
- Remove any sensitive data you don’t want to share
- Search for your domain and replace with “example.com”
- Search for sensitive IPs and replace
- Share with support:
- Attach Guard Dog entries to support forum post
- Or paste relevant excerpts only
- Include: WordPress version, PHP version, Guard Dog version
Advanced Usage
Log File Location
Direct file access (via FTP/SSH):
/wp-content/debug.log
Guard Dog writes to the standard WordPress debug log file, which may also contain entries from WordPress core and other plugins.
Tailing Logs (Linux/Mac)
Monitor logs in real-time:
tail -f /path/to/wp-content/debug.log
Searching Logs (Command Line)
Find specific Guard Dog events:
# Find all Guard Dog CAPTCHA errors
grep "Guard Dog.*ERROR.*CAPTCHA" /wp-content/debug.log
# Find all Guard Dog events for specific IP
grep "Guard Dog" /wp-content/debug.log | grep "203.0.113.50"
# Count Guard Dog login failures
grep "Guard Dog.*Login Limiting.*Failed login" /wp-content/debug.log | wc -l
# View only Guard Dog entries
grep "Guard Dog" /wp-content/debug.log
Integrating with External Tools
Splunk, ELK, Graylog:
- Parse Guard Dog log format
- Import into log aggregation platform
- Set up alerts and dashboards
Log rotation tools:
- logrotate (Linux)
- Compress old logs
- Archive to cloud storage
Performance Impact
By Log Level
| Level | Performance Impact |
|---|---|
| ERROR | Negligible (<1%) |
| WARNING | Minimal (1-2%) |
| INFO | Low (2-5%) |
| DEBUG | Moderate (5-15%) |
Recommendation: Use ERROR or WARNING in production, INFO/DEBUG only when troubleshooting.
Disk Space Impact
Typical daily log sizes (medium-traffic site):
- ERROR: 0.1-0.5 MB
- WARNING: 0.5-2 MB
- INFO: 2-10 MB
- DEBUG: 10-50 MB
High-traffic sites (100k+ visitors/day):
- DEBUG level could generate 100+ MB/day
- Monitor disk space
- Use automatic rotation
Troubleshooting Debug System
Logs Not Appearing
Issue: Enabled logging but no logs appear
Causes:
- File permissions (can’t write)
- Disk space full
- PHP errors preventing logging
Solutions:
- Check
/wp-content/directory is writable (755 permissions) - Verify WordPress debug logging is enabled (WP_DEBUG_LOG in wp-config.php)
- Check PHP error logs for Guard Dog errors
- Verify Guard Dog debug logging is enabled in settings
- Check
/wp-content/debug.logfile exists and is writable
Can’t Access Logs
Issue: Can’t view or access debug logs
Causes:
- File too large to view in browser
- Server timeout loading large file
- File permissions preventing access
Solutions:
- Access via FTP to download
/wp-content/debug.log - Use command line to view file (SSH access)
- Clear logs to reduce size
- View file in chunks using text editor
- Check file permissions (should be 644 or 664)
Logs Missing Events
Issue: Expected events not in log
Causes:
- Wrong log level (too high)
- Event occurred before logging enabled
- Event doesn’t trigger logging
Solutions:
- Lower log level to INFO or DEBUG
- Clear logs and reproduce
- Verify feature is actually running
Best Practices
- ✅ Use ERROR level in production unless troubleshooting
- ✅ Enable INFO/DEBUG only when needed then disable
- ✅ Download logs before clearing for records
- ✅ Monitor disk space with DEBUG level
- ✅ Sanitize logs before sharing remove sensitive data
- ✅ Use appropriate level for issue don’t always use DEBUG
- ✅ Review logs regularly catch issues early
- ✅ Clear logs after troubleshooting reduce disk usage
- ✅ Document findings note what you discovered
- ✅ Disable when done avoid performance impact