Table of Contents
Where to Find Critical Logs
/var/log/syslog— General system messages/var/log/auth.log— Authentication attempts (SSH logins, sudo)/var/log/nginx/access.log— All NGINX requests/var/log/nginx/error.log— NGINX errors/var/log/mysql/error.log— MySQL errors/var/log/apt/history.log— Package installation history
Analyzing NGINX Access Logs
# Top 10 IPs by request count
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -10
# Top requested URLs
awk '{print $7}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -20
# 500 errors today
grep " 500 " /var/log/nginx/access.log | grep $(date +%d/%b/%Y)Automated Log Monitoring with GoAccess
GoAccess provides real-time terminal-based log analysis: apt install goaccess && goaccess /var/log/nginx/access.log -c
Log Rotation
Configure /etc/logrotate.d/nginx to rotate logs daily and keep 14 days. Without rotation, logs grow until they fill your disk.
FAQ
How do I find the cause of a 502 Bad Gateway error?
Check /var/log/nginx/error.log for the exact time of the 502. Look for upstream connection failures or timeout messages. Then check your application logs for crashes or slow responses.
Ready to deploy?
Full Root Access VPS for Log Management
Deploy ELK Stack, Loki, or any log aggregation solution on Power Down VPS.
