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
>
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/pg8yhkEZTzsJ.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.