参考网址:
[url]http://github.com/wvanbergen/request-log-analyzer[/url]
[url]http://www.letrails.cn/archives/rails-performance-optimization-guide/[/url]
[url]http://wiki.github.com/wvanbergen/request-log-analyzer/basic-usage[/url]
Getting started
Use RubyGems to install request-log-analyzer on your computer:
$ gem install request-log-analyzer
Now you can run request-log-analyzer to analyze a log file:
$ request-log-analyzer log/production.log
Basic usage
If you want to analyze a Rails production log file, use the following syntax:
$ request-log-analyzer production.log
This will generate a report, similar to our Sample output. If you want analyze multiple files (because of logrotate or multiple mongrel log files), you can provide multiple filenames or use wildcards. The files will be process in the order that they are given on the command line.
$ request-log-analyzer mongrel.2008-11.log mongrel.2008-12.log mongrel.2009-01.log
$ request-log-analyzer production.*.log
Parsing from the standard input
Request-log-analyzer can also parse the standard input by using - or STDIN as filename. This is great in combination with the UNIX tail -f command to parse information live, as it is written to the log file.
$ tail -f production.log | request-log-analyzer -
Request-log-analyzer will then parse any information that is written to the log file until it is stopped by pressing CTRL+C, after which it will present the performance report for all data that has been collected up to that point.
Examples
Write an HTML report to report.html:
$ request-log-analyzer log/production.log --file report.html --output HTML
Only use uncolored ASCII characters in the report:
$ request-log-analyzer log/production.log --boring
Create a database named requests.db with all parsed request information
$ request-log-analyzer log/production.log --database requests.db