Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How to log session variables in Rails 3.2?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Chirag  
View profile  
 More options May 11 2012, 11:42 am
From: Chirag <chirag.sing...@gmail.com>
Date: Fri, 11 May 2012 08:42:01 -0700 (PDT)
Local: Fri, May 11 2012 11:42 am
Subject: How to log session variables in Rails 3.2?

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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bo Jeanes  
View profile  
 More options Jun 14 2012, 3:41 pm
From: Bo Jeanes <m...@bjeanes.com>
Date: Thu, 14 Jun 2012 12:41:57 -0700 (PDT)
Local: Thurs, Jun 14 2012 3:41 pm
Subject: Re: How to log session variables in Rails 3.2?

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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »