How to follow what’s going on in your Apache server logs (linux)

At the command line type:

tail -f /var/log/apache2/access.log

As apache requests are received you’ll see information about them appear on screen.

Can’t find the log file?
Try this:

find /var -name access.log 2>/dev/null

This searches for the file “access.log” in the /var directory and sub-directories. The “2>..” on the end is a really neat trick which directs all error messages to /dev/null so you don’t get messages about permission denied on directory traversal.

If this doesn’t find the file then it’s probably not in /var so try:

find / -name access.log 2>/dev/null

Which will search from /

Combine the find command with the tail command

tail -f `find /var -name access.log 2>/dev/null`

Note the wierd backtick character around the find.

Filtering the results
If you’re looking for something in particular then pipe the results through grep to filter on a string:

tail -f /var/log/apache2/access.log | grep login.php
Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter

Leave a Comment