I need a unique request ID for my logger, so I can track each request in the log file.
So far I got this
REQUEST_ID = Digest::MD5.hexdigest(Time.now.
Follow-up to the answer using log_tags
, since :uuid is only unique among a request, it is difficult to use it with session tracking.
I found log_tags accept a Proc, and pass a request object as an parameter. So, following code will stamp all of log entry with session_id (assuming you're using ActiveRecord based session store)
config.log_tags = [ lambda {|req| "#{req.cookie_jar["_session_id"]}" }, :remote_ip, :uuid ]