Viewing Rails log file on a production server

The Rails log file is a great way to see what your app is doing, but what do you do when the incoming request rate goes up, like on your production server?

Typically, you’ll be using tail to view the latest requests, and you’ll see something like this:

Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:42) [GET]
  Session ID: 88a032a331d5eca72e75e6880ec55016
  Parameters: {"action"=>"index", "controller"=>"my"}
...
...
Rendering ...
Rendering my/index
Completed in 0.10900 (9 reqs/sec) | Rendering: 0.06200 (56%) | DB: 0.03200 (29%) | 200 OK [http://localhost/]

Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:42) [GET]
  Session ID: 88a032a331d5eca72e75e6880ec55016
  Parameters: {"action"=>"index", "controller"=>"my"}
...
...
Rendering ...
Rendering my/index
Completed in 0.10900 (9 reqs/sec) | Rendering: 0.06200 (56%) | DB: 0.03200 (29%) | 200 OK [http://localhost/]

When you start getting a few of these a second, this method becomes unusable.

Here’s how I get around that, but can still watch in real time.

tail -f production.log | grep "Processing "

This gives me an output that looks like this:

Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:42) [GET]
Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:43) [GET]
Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:44) [GET]
Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:45) [GET]
Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:46) [GET]
Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:47) [GET]
Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:48) [GET]
Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:49) [GET]
Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:50) [GET]
Processing MyController#index (for 127.0.0.1 at 2006-12-06 18:55:51) [GET]

This is less informative, but allows me to keep up with what my server is doing in real time.

The next question is: What happens when I get so many requests that this technique becomes useless?

This entry was posted on Thu, 07 Dec 2006 05:04:21 GMT . You can follow any any response to this entry through the Atom feed. You can leave a comment .
Tags


Comments

Leave a response

Leave a comment