Tips and tricks to tail -f /var/log/apache2/access.log

Top 10 who

cat access.log | awk '{print $3}' | sort | uniq -c | sort -nr | head -n 10

Top 10 from access.log with awk

awk '{ print $1}' /var/log/apache2/access.log | sort | uniq -c | sort -nr | head -n 10

Include

tail -f access.log | grep '118.189'

Exclude

tail -f access.log | grep -v '118.189'

Exclude multiple strings

tail -f access.log | grep -v -e '118.189' -e '157.230'

Exclude and include

tail -f access.log | grep -v 'excluded string' | grep '118.189'

# Or

tail -f access.log | grep -vE 'excluded|string' | grep 'included'

Leave a Comment

Your email address will not be published. Required fields are marked *