Overview
Thelog command provides real-time log viewing and log management for all server components. Monitor access logs, debug errors, and manage log retention.
Basic Usage
Nginx Logs
Access Logs
View Nginx access logs:Error Logs
View Nginx error logs:View error logs instead of access logs
WordPress Logs
Enable Debug Mode
Enable WordPress debug logging:WordPress debug mode:
on- Enable debug loggingoff- Disable debug loggingtrue- View debug log (if enabled)
Control debug display:
off- Log errors but don’t display on screen (recommended)- (omit) - Display errors on screen (default when enabling)
WP_DEBUG = true- Enable debug modeWP_DEBUG_LOG = true- Log to/wp-content/debug.logWP_DEBUG_DISPLAY- Show errors on screen (if-displaynot set tooff)
View WordPress Debug Log
/var/www/example.com/htdocs/wp-content/debug.log
WordPress debug mode must be enabled first. If logging is off, viewing will show an error.
Disable Debug Mode
Set Environment with Debug
Combine with environment setting:PHP Logs
PHP-FPM Logs
View PHP-FPM error logs:MySQL/MariaDB Logs
Error Log
View MySQL/MariaDB error log:General Log
Enable and view general query log:Enable the specified MySQL log type
Disable the specified MySQL log type
Slow Query Log
Enable and view slow query log:Queries taking longer than this (in seconds) are logged. Default is 10 seconds.
Binary Log
Enable and view binary log (for replication):Binary log expiration time in seconds. Default is 2592000 (30 days).
Binary logs are required for MySQL replication and point-in-time recovery.
Mail Logs
Mail and SMTP Logs
View mail server logs:/var/log/mail.log- Mail delivery log/var/log/mail.err- Mail errors
System Logs
Let’s Encrypt Logs
View Let’s Encrypt/Certbot logs:SSH/Auth Logs
View authentication and SSH logs:Syslog
View system log:Log Configuration
Access Log Control
Enable or disable access logging:Access log control:
on- Enable access loggingoff- Disable access logging
Access Log Buffering
Optimize access log performance with buffering:Log buffer configuration:
[buffer_size_kb,flush_time_minutes]- First value: Buffer size in kilobytes
- Second value: Flush interval in minutes
[32,5] = 32KB buffer, flush every 5 minutesBuffering improves performance by reducing disk writes, but logs may be delayed by up to the flush interval.
Log Viewing Options
Custom Line Count
Control number of lines displayed:Number of lines to display from the end of the log file
Log Management
Purge Old Logs
Delete old compressed log files:Purge log files:
true/all- Purge all .gz logs (prompts for confirmation)force- Purge all without confirmationnginx- Purge only Nginx .gz logsmysql- Purge only MySQL .gz logsletsencrypt- Purge only Let’s Encrypt .gz logsredis- Purge only Redis .gz logsjournal- Clean systemd journal (keeps 7 days)
Real-Time Monitoring
All log commands show real-time updates usingtail -f:
Examples
Debug WordPress Issues
Monitor High Traffic Site
Debug Database Issues
Debug SSL Issues
Audit Security
Optimize Performance
Clean Up Disk Space
Log Locations Reference
Nginx
- Global access:
/var/log/nginx/access.log - Global error:
/var/log/nginx/error.log - Site access:
/var/log/nginx/[domain].access.log - Site error:
/var/log/nginx/[domain].error.log
PHP
- PHP-FPM:
/var/log/php/[version]/fpm.log
MySQL/MariaDB
- Error:
/var/log/mysql/error.log - General:
/var/log/mysql/mysql.log - Slow query:
/var/log/mysql/mariadb-slow.log - Binary:
/var/log/mysql/mariadb-bin
WordPress
- Debug:
/var/www/[domain]/htdocs/wp-content/debug.log
System
- Mail:
/var/log/mail.logand/var/log/mail.err - Let’s Encrypt:
/var/log/letsencrypt/letsencrypt.log - Auth/SSH:
/var/log/auth.log - Syslog:
/var/log/syslog
Troubleshooting
Log File Not Found
Empty Log File
If log exists but shows “Log File is Empty”:Permission Denied
All log commands require sudo:High Disk Usage
Notes
- All commands require
sudo(root privileges) - Logs are displayed in real-time using
tail -f - Press
Ctrl+Cto stop viewing logs - Compressed (.gz) logs are created by logrotate
- MySQL logs require restart when enabling/disabling
- WordPress debug logs can grow large - monitor size
- Use
-helpto see all available options
See Also
- Site Management - Manage sites that generate logs
- Webinoly Command - Server configuration
- HTTP Auth - Monitor authentication attempts in logs