Logging in Rails with a per-request ID

Viewed 8549

I'm looking for a quick and easy way to generate a unique per-request ID in rails that I can then use for logging across a particular request.

Any solution should ideally not make too much use of the default logging code, as I'm running the application under both jruby and ruby.

4 Answers

This is now a feature of rails:

class WidgetsController < ApplicationController
  def get
    puts request.request_id
  end
end
Related