I need to parse a big log file to get the ipadress, datetime, source and client from all the records.
The following link with the regex works:
Regex:
(?<ipAddress>.*?)\s-\s-\s\[(?<dateTime>.*?)\]\s\"GET\s(?<source>.*?)\"\s[0-9]+\s[0-9]+\s\"-\"\s\"(?<client>.*?)\"
Maybe the format is not ok for PHP ?
I open the file as such:
$filename = "access-streaming_small.log"
$file = popen("tac $filename", 'r');
If I use :
while ($line = fgets($file)) {
echo $line;
}
I get the full log file which is displayed ok.
I need to process it with regex so that I get variables of ipadress, datetime, source and client from all records contained in the log file. Bonus task: I need to filter results to get the most current details of the records generated in the last 10 minutes compared to current time.