My thinking is to capture the session_id and store it in thread local storage, e.g.
Thread.current[:session_id] = session[:session_id]
But some rails logging occurs before my filter is called.
I thought I might capture the session_id by writing a middleware plug-in. But again, I don’t seem to get it early enough for all logging.
What is the earliest that I can capture session_id?
Thanks!
Since Rails 3.2 support tagged logging using
log_tagsconfiguration array,log_tagsarray accept a Proc object, and the proc object is invoked with a request object, I could configure thelog_tagsfollowing way:It’s working with Rails 3.2.3, with ActiveRecord’s session store is in use.