The default Nginx logs can be combined and sorted to gather some useful stats.
- Make a working directory and copy current logs over (optional):
mkdir ~/accesslogs
sudo cp /var/log/nginx/access.log* ~/accesslogs
cd ~/accesslogs - Extract logs compressed by log rotate:
ungzip *.gz
- Make a big combined log:
sudo cat access.log* >> log.combined
- Parse the combined log and count the 404’s
sudo awk '($9 ~ /404/)' log.combined | awk '{print $7}' | sort | uniq -c | sort -rn >> 404sC.txt