Apache, Linux

Retrieve useful information from Apache logs

Common locations where you can find Apache logs are /var/log/apache2 and /var/log/httpd/. You can extract valuable information from your apache logs. Here are some useful examples!

Extract unique IP addresses:

cat /var/log/apache2/access.log | awk '{print $1}' | sort | uniq

 

Extract unique IP addresses with datetime stamp:

cat /var/log/apache2/access.log | awk '{print $1 " " $4}' | sort | uniq

 

Extract unique IP addresses and browser:

cat /var/log/apache2/access.log | awk '{print $1 " " $12 " " $19}' | sort | uniq

 

Extract unique IP addresses and OS:

cat /var/log/apache2/access.log | awk '{print $1 " " $13}' | sort | uniq

 

Extract unique IP addresses, datetime and request method:

cat /var/log/apache2/access.log | awk '{print $1 " " $4 " " $6}' | sort | uniq

 

Extract unique IP addresses, datetime and request uri:

cat /var/log/apache2/access.log | awk '{print $1 " " $4 " " $7}' | sort | uniq