Access Log Filtering Program?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Access Log Filtering Program?

Post by JAB Creations »

I'm wondering if there is a program out there that will scan an access log and gives the option to delete or keep lines with certain strings? For example if you wanted to view a version of your access log that only contained POST methods, any line that did not contain the string "POST" would be removed from the log.
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Post by VladSun »

Is it Linux?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

XP please.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

Ya, it's called PHP :)
fopen(), fopen(), fgets(), if (preg_match()) fputs(), fclose(), fclose()
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

file_get_contents() ;)

I can't think of a specific tool for XP.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

Maugrim_The_Reaper wrote:file_get_contents() ;).
For multi-megabyte log files? Not a good idea.
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post by ReverendDexter »

you could always get Cygwin, then just pipe the output of a grep to an output file.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

Oh, yeah, that is a possibiilty too, there's lots of native win32 ports a well.
http://gnuwin32.sourceforge.net/
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

A clarification: My PHP skills are at best maybe 2.5/10 and I would not claim to know OOP at the moment. Additionally software needs to already be a binary for XP (installer or just extract is fine).
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post by ReverendDexter »

That's the beauty of grep... all you'd have to do is go to your log directory, and do a "grep 'POST' file.log > post_only_log.txt" (double check my syntax, but it should be close), then use your favorite text editor/viewer to read your newly created post_only_log.txt file. And, grep takes regex, so you can make it as specific as you want for which lines go into your filtered log files, no PHP required.
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

http://gnuwin32.sourceforge.net/packages/grep.htm
I found grep / binaries and this isn't obviously simplified. Eventually found the dependencies and after using /? switch I'm getting the message grep: (standard input): not enough space
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post by ReverendDexter »

how exactly are you invoking it? i.e. what's the command you're using?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Post by JAB Creations »

grep /?
User avatar
ReverendDexter
Forum Contributor
Posts: 193
Joined: Tue May 29, 2007 1:26 pm
Location: Chico, CA

Post by ReverendDexter »

oh, <smacks self in forehead>, sorry, my brain didn't parse '/?' at all when I read your post. If you're wanting help using it, I'd just consult the online manual.

Basially it's "grep [options] 'regexstring' location", so "grep -ir 'toast' ." will do an case insenstive search for lines containing "toast" in this directory and recurse through all subdirectories of this one. (-i is case insensitive, -r is recursion).
Post Reply