Re: Parsing access_log entries

From: Date: Fri, 08 Dec 2000 00:31:53 +0000
Subject: Re: Parsing access_log entries
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-29253@lists.php.net to get a copy of this message
If you do $row=explode(' ",$line), you'll get $row[0] - IP address $row[1] - "-" $row[2] - "-" $row[3] - [Date/Time $row[4] - GMT offset] $row[5] - "GET or "POST $row[6] - document $row[7] - protocol" $row[8] - status $row[9] - something else. You should be able to get anything you need from that with minimal extra processing. John Biesnecker wrote: > > The problem with that method is that there are spaces within each line that > aren't field deliminators. That's why I was thinking regular expressions... > > Thanks, though. > > /s/ John > > ----- Original Message ----- > From: "Joe Stump" <joe@earth.care2.com> > To: "John Biesnecker" <amraam@ao.net> > Cc: <php-general@lists.php.net> > Sent: Thursday, December 07, 2000 5:45 PM > Subject: Re: [PHP] Parsing access_log entries > > > Real time eh? Well I would recommend this: > > > > <? > > > > $fp = fopen('/dev/stdin','r'); > > while(!feof($fp)) > > { > > $line = trim(fgets($fp,4096)); > > $array_of_line = explode(' ',$line); > > // parse based on that. > > } > > > > ?> > > > > Or in your main include file (we all have one!) put a function in the logs > the > > info you want to a DB. > > > > --Joe > > > > > > On Thu, Dec 07, 2000 at 05:41:31PM -0500, John Biesnecker wrote: > > > Hello all.... > > > > > > I'm trying to parse my Apache access_log files in real time. I'm > looking > > > for a function or something to split a line in the access_log into an > array > > > that i could then parse. I was thinking a regular expression would do > the > > > trick, but my skills in that area are poor to none. > > > > > > Thanks for the help. > > > > > > /s/ John > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > > For additional commands, e-mail: php-general-help@lists.php.net > > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > --- > > Joe Stump > > PHP Programmer > > www.Care2.com > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#29253) next »