How to make a small shell script to improve readibility of Apache logs output?

I created one some time ago for myself because raw Apache output generated too much output.

This is a script to quickly see what users do in phpBB3 forum board.

Extremely simple – only tail and awk used!

Some time ago i created a forum on phpBB3 script. Apache logs are not to clear so i decided to wrote small script for myself for better visibility. I don’t want to change default apache log format.
I still use this script sometime to check what is happening currently on site.

001. Script.

Script is easy. You can change it to fulfill your expectations. Make restrictions to hide more unwanted informations of delete part of code do show which i hid.

vi wwwlog.sh
chmod +x www.log.sh

…. and fire it…


002. How this look working?

Example of output

Example of output

003. Some info to help You modify script for Your requirements


How much lines from previous entries are processed and displayed



Full path to apache log


gsub ( "http://forum.domain.pl/|", "");

Replace forum address (visible as “http://forum.domain.pl/” or direct ip “” – replaced with nothing – removed to shortcut path displayed on screen.


if ( ($1 != "") && ($1 != "") ....

This is entire case, i removing few adresses from display. is address of my computer – i don’t want to see it
“” – another address what i don’t want see


&& (substr($7,2,6) != "styles")

I don’t want to see entries where this word is used in that position.


&& (substr($7,2,6) != "mchat.")

I also hide mchat communication with server


&& (substr($7,2,6) != "downlo")

Download links are hidden


&& (substr($7,2,6) != "images")

Images also not shown (but check them sometime anyway for errors)


etc…. Remove or add additional filters depend what You need to see.


Now about displayed columns:

printf "\033[1;31m" substr($4,2) " \033[0m"

Change color to red, display cuted date and time and change color back to white


"\033[1;35m" $9 "\033[0m"

Apache summary code displayed (HTTP 200 = OK etc.) to quickly obtain if i have problems with site…


if ( $6 == "\"GET" ) {printf " -> GET ";} };

If sixth column value is GET, display it as ” -> GET ”


if ( $6 == "\"POST" ) {printf "\033[1;44m <-- POST \033[0m";} };

Especilly display POST method colorized (usually it means that someone make an new entry) – look at picture.


if ($1 != "::1") { print "\033[1;33m" $11 \

Display entered link


"\033[0m \033[1;32m" $7 "\033[0m"}}} \

Display from user arrived (prev page)




This script is easy to make and modify, but are usefull (for me) to quickly overview see what people doing on forum.