Paypal Donate

Web log entry filtering

The attached script is a simple script written to process Apache access logs (though will work with other access logs too, it just depends upon the format).

Use the array to list all the source host names (or IP addresses) from the log - the script processes the entire log and writes two new ones (which you also specify).  One of the logs contains all your access logs, and the other one the interesting info (i.e. everyone else!).

If you have a Joomla site you will know how many log entries are created by your own editing - and I certainly don't want to have to wade through all of them when glancing through the log.


' Script written by David Barrett
' Copyright 2009
' http://www.cedit.biz/
'
This script is licensed under the Creative Commons
' Attribution 2.5 Licence
' http://creativecommons.org/licenses/by/2.5/
'

' You are free to use it for both personal and
' commercial purposes, so long as full attribution
' is given to the author (David Barrett).
'
' This notice must not be removed
'
'

dim strSourceLog
dim strMyLogs
dim arrMyClients

strSourceLog="C:\logs\cedit.biz-access.log"
strMyLogs="C:\logs\cedit.biz-access-mine.log"
strInterestingLogs="C:\logs\cedit.biz-access-other.log"
arrMyClients=Array("34.12.43.12",_
"192.168.0.3",_
"192.168.0.4",_
"blah.mshome.net")

dim fso, r, t, w
dim strLine, blnMine, i

set fso=CreateObject("Scripting.FileSystemObject")
set r=fso.OpenTextFile(strSourceLog,1)
set w=fso.CreateTextFile(strMyLogs,true)
set t=fso.CreateTextFile(strInterestingLogs,true)

while not r.AtEndOfStream
strLine=r.ReadLine
blnMine=false
for i=0 to UBound(arrMyClients)
if Left(strLine, Len(arrMyClients(i)))=arrMyClients(i) then
blnMine=true
exit for
end if
next
if blnMine then
w.Writeline strLine
else
t.WriteLine strLine
end if
wend

t.close
r.close
w.Close
Copyright © 2009 www.cedit.biz. All rights reserved.