#97 Analyzing the Production Log
Mar 17, 2008 | 5 minutes | Performance, Tools
In order to improve performance of your Rails application you need to find the bottlenecks. A great starting point is your production log. In this episode you will see how to use RAWK to analyze your log file and determine which controller actions take up the most processing time.
really nice and handy, waiting for more ;-)
Félicitations pour votre formidable travail, à la fois pertinant et très utile.
i really wish you'd do more casts on some more basic things, they were great! ... these things are way over my head ;-(
But maybe it's just me.
Looks very interesting, am looking forward to the next episodes.
One thing though, how exactly do you get the log to show this pid's?
I cannot get my 2.0.2 to alter the log messages, and thus cannot group by controller actions.
Perhaps a sample environment.rb and a sample log would clear it up for people as thick as me ;-)
I have to say that I have learned so much watching your railscasts, it really been such a great help at my job. The only thing else i could ever ask for is more examples.. will be watching your rss feed ;)
I've had success using Rawk to analyze several gigs of logs. It's really nice if you have logs spread out over a number of machines. It's easy enough to cat them together and send them to Rawk. Rawk seems to be pretty fast and provides very useful output <b>without</b> the need to modify the logger.
My favorite flag is -w 20 which will give the 20 worst requests. If you have a very high traffic site these 20 worst offenders might be hogging up mongrels or your DB (-d).
Waiting for the follow up to this.
Just started using RoR a couple of weeks ago... by accident. A client moved to a new host and they offer RoR as part of the package for all customers.
I never heard of it before.
I had already started building a PHP job tracking application for the client and when I realized what RoR was... I scrapped the whole thing and started over. YEEEHAAA! This is rocking my world.
Now my brain is exploding. Had to delete all those Love Boat reruns to learn this stuff.
These Railscasts are FANTASTIC! I have one tiny small criticism... that intro scares me. I have to fast forward my DVDs when it plays that THX promo (the audience is NOT listening)... same thing here. I have to fast forward past that Railscast intro or I get anxious.
Other than that these are PERFECT and very very helpful.
I know exactly what you mean, I always skip past the beginning, too, though it's because I'm usually at work, and I'm afraid somebody will misunderstand what I'm doing (no one here understands what I actually do anyways) and think I'm just streaming entertainment. Well, I'm sorry, but my entertainment is educational and what lets me do this 'magic' that I do all day.
@drozzy, the next few episodes will be a bit more advanced, but in the near future I hope to bring in some more basic ones. Thanks for the suggestion!
@Morgan, oops! I completely forgot to address this issue! Rails 2.0 uses a BufferedLogger which I'm not sure allows you to customize the format as easily. Instead you can switch back to the old logger. I *believe* this line will do it in the config file, but I haven't tested it yet.
config.logger = Logger.new(config.log_path)
Thanks for catching that.
@Vern & Carl, sorry about the intro. I'll consider changing the sound effect. Maybe a nice little squeaky toy or something. ;)
@Ryan, you could do it as a psychological experiment. Pavlov would be proud at the way you've got at least a couple of us trained to drool (or jump) at that sound, I'm sure.
Hee i just want to give u a big thank you for your fantastic railscast! I'm looking forward to the next episodes!
Although not the most elegant of solutions, but you can just patch the add method of the BufferedLogger in case you want to keep it.
Create a file custom_logger.rb in your initializers folder and paste the content of the pastie in it (it only puts pid in the log message in production mode, it's less ugly):
I've upgraded to Rails 2.1.0 and I can't get the logger to change, so I can't group by controller actions. Without that its really hard to make anything useful out of the log. I tried Peter's pastie code for Rails > 2.0 but Active record crashes with this code in my environment.rb
Any help would be great, because this looks like a great tool.
I am the author of request-log-analyzer (http://github.com/wvanbergen/request-log-analyzer/), an open-source command line tool to analyze production logs.
It is a bit more advanced than rawk and produces more detailed reports: http://wiki.github.com/wvanbergen/request-log-analyzer/sample-output
Maybe it can be of help if you are trying to find the bottlenecks in your application.
Thanks for making and maintaining this, Willem.
It is really a gud job!!. Keep on increasing my rails learning curve through RailsCasts. Thanks to Ryan Bats
RAWK does not appear to work with recent versions of rails.
After some digging around, found this newer and maintained gem called request-log-analyzer, which does very similar work. And I love the output formats that it produces. Highly recommended https://github.com/wvanbergen/request-log-analyzer