Skip to Content
Ruby on Rails® for Microsoft Developers
book

Ruby on Rails® for Microsoft Developers

by Antonio Cangiano
April 2009
Intermediate to advanced content levelIntermediate to advanced
479 pages
12h 55m
English
Wrox
Content preview from Ruby on Rails® for Microsoft Developers

6.6. Logging

Both this and the previous chapter mentioned that you could see the executed queries, errors, and other details about the requests in a log file. Depending on the environment you are in, Rails will log a certain amount of information in log\development.log, log\test.log, or log\production.log. The log folder will also contain a server.log file for the Web server (for example, Mongrel).

When you look at the development.log file after having visited the front page of the blog, you see an entry similar to the following:

Processing ArticlesController#index (for 127.0.0.1 at 2009-01-28 11:28:11) [GET]
  [4;36;1mArticle Load (0.0ms)[0m   [0;1mSELECT * FROM "articles" WHERE (published
= 't' AND published_at <= '2009-01-28 16:28:11') ORDER BY published_at DESC LIMIT 1
OFFSET 0[0m
[4;35;1mSQL (0.0ms)[0m   [0mSELECT count(*) AS count_all FROM "articles" WHERE
(published = 't' AND published_at <= '2009-01-28 16:28:11') [0m
Rendering template within layouts/articles
Rendering articles/index
  [4;36;1mSQL (0.0ms)[0m   [0;1mSELECT count(*) AS count_all FROM "comments" WHERE
("comments".article_id = 2) [0m
Rendered articles/_article (10.0ms)
Completed in 29ms (View: 18, DB: 0) | 200 OK [http://localhost/]

This tells you a whole lot of information: the type of request received, the IP it came from and the timestamp, which controller and action executed your request, the rendered templates, and the queries that were executed behind the scenes. It also tells you the time that it took to execute ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ruby on Rails™ 3 Tutorial: Learn Rails™ by Example

Ruby on Rails™ 3 Tutorial: Learn Rails™ by Example

Michael Hartl

Publisher Resources

ISBN: 9780470374955Purchase book