What if I need to analyze the access log now?
Like analyzing D:\Servers\Apache2.2\logs\access2014-05-22.log .
http://my.oschina.net/cart/ developed a gadget to analyze Apache logs, split the word interleaved CSV file and insert MySQL database analysis for this issue
<?PHP$date= ' 2014-05-22 ';file_put_contents($date.‘. CSV ', ' ');file_put_contents($date.‘. CSV ', ' "IP", "Date", "Zone", "Protocol", "URL", "Version", "Status", "Size", "Referer", "user-agent". " \ r \ n ",file_append);Preg_match_all(‘/(.*?) .*? .*? \[(.*?) (.*?) \] "(.*?) (.*?) (.*?)" (.*?) (.*?) "(.*?)" "(.*?)" /isu ',file_get_contents(‘.. /servers/apache2.2/logs/access '.$date.‘. Log '),$matches);$num=Count($matches[0]); for($i= 0;$i<$num;$i++){ file_put_contents($date.‘. CSV ', ' ".Trim($matches[1] [$i]).‘","‘.$matches[2] [$i].‘","‘.$matches[3] [$i].‘","‘.$matches[4] [$i].‘","‘.$matches[5] [$i].‘","‘.$matches[6] [$i].‘","‘.$matches[7] [$i].‘","‘.$matches[8] [$i].‘","‘.$matches[9] [$i].‘","‘.$matches[10] [$i].‘"‘." \ r \ n ",file_append);}
Finally, in MySQL, according to the CSV field information to establish the field, through the MySQL CSV using LOAD DATA import your CSV file.
Import 2G of CSV log, the speed is very fast!!!
All rights reserved:http://my.oschina.net/cart/
Haha, http://my.oschina.net/cart/log has been successfully split into the database, the remaining how to screen, how to toss http://my.oschina.net/cart/, with your intention! Ha ha!