Hey,
I know this is a few months old, but I ran into the same issue and have a
(pretty hacky) solution. I put this into my `config/application.rb` in
order to have access to the session in my log_tags:
config.middleware.delete(ActionDispatch::Cookies)
config.middleware.delete(ActionDispatch::Session::CookieStore)
config.middleware.insert_before(Rails::Rack::Logger,
ActionDispatch::Session::CookieStore)
config.middleware.insert_before(ActionDispatch::Session::CookieStore,
ActionDispatch::Cookies)
# Now this works:
config.log_tags = [:uuid, proc { |request| request.session[:user_name]
|| 'Anonymous' }]
Hope this helps somebody else down the track.
Cheers,
Bo
On Friday, May 11, 2012 10:42:01 AM UTC-5, Chirag wrote:
> Rails 3.2 introduced tagged logging, is it possible to log session
> variables like session[:user_id] using that?
> Tried adding that using a lambda, but session is not decrypted when the
> logger middleware is called.
> Is there any other way to get the session variables logged against each
> line that is added in the log file?
> Thanks
> Chirag