开发者

Looking for a PHP class to parse an access.log file [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

We don’t allow questions seeking recommendations for books, tools, software libraries, and mor开发者_Python百科e. You can edit the question so it can be answered with facts and citations.

Closed 4 years ago.

Improve this question

Let's say I have an Apache Web server, with the default access.log file for a website. I'm looking for a PHP class to dissect it and give me info. Better than that, I'd love a PHP class that would simply dissect the following line (as an example):

123.125.66.111 - - [19/Aug/2010:17:21:23 +0000] "GET /robots.txt HTTP/1.1" 404 409 "-" "Baiduspider+(+http://www.baidu.com/search/spider.htm)"

Any ideas? thx in advance


if you notice, the access log is not much different from a CSV,
especially if you are using tab as separator, pretty sure fgetcsv fit the shoe


This is from what Ish Kumar said:

http://www.php-scripts.com/php_diary/012103.php3

Also, his search was a good one:

http://www.google.ca/search?sourceid=chrome&ie=UTF-8&q=php+parse+log+files


There is an old symfony plugin buth the classes should be usable anywhere else: http://trac.symfony-project.org/browser/plugins/tmApacheLogParserPlugin


Depending on what you are doing with it and how much data is in the log, why not loop through it, split by a space and do what you need to do in the body of the loop? You haven't said what you are doing with the data.


Did you try awstats (look at the demo and the features)? My Webhoster has awstats installed and I am quite happy with it.


Other PHP based solutions that are still maintained:

  • https://github.com/kassner/log-parser
  • http://pimpmylog.com/

And if you are into Matomo/Piwik, you can import the logs (python required)

  • https://github.com/matomo-org/matomo-log-analytics
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜