Sometimes too much of a good thing (log info) is a bad thing, and that’s true with Rails default logging. Check out the gem ’lograge’. The big difference is that a single request will take a single line. To quote the README, instead of logs like this:
Started GET "/" for 127.0.0.1 at 2012-03-10 14:28:14 +0100 Processing by HomeController#index as HTML Rendered text template within layouts/application (0.0ms) Rendered layouts/_assets.html.erb (2.0ms) Rendered layouts/_top.html.erb (2.6ms) Rendered layouts/_about.html.erb (0.3ms) Rendered layouts/_google_analytics.html.erb (0.4ms) Completed 200 OK in 79ms (Views: 78.8ms | ActiveRecord: 0.0ms)
After installing lograge, you’ll have one line for the request:
method=GET path=/jobs/833552.json format=json controller=jobs action=show status=200 duration=58.33 view=40.43 db=15.26
The one issue with lograge
is that the default configuration does not log
request parameters, which can be useful for debugging. This blog post, How to add
request parameters to lograge logs, addresses that shortcoming.
This is a companion discussion topic for the original entry at http://www.railsonmaui.com//blog/2013/05/08/strategies-for-rails-logging-and-error-handling/