-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error logging session variable: undefined method `[]=' for nil:NilClass #41
Comments
Hi If you put rails 4.2.x ver 0.4.0, you will encounter the bug. Investigate the bug and fix it. Thank you very much! |
Hi, I am having the same issue with rails 5. |
Thanks!
Which version occurred in Rails 5?
If you support Rails 4.2, change the action in railtie version in the method. |
still encountering this issue |
and still encountering this in 2020. |
and still in 2021 |
and still in 2023 |
Hi! New maintainer here. I think we need to add a middleware to this gem for now to ensure we have the request object available. |
Setup
I followed the setup in the README to replace the local logger:
Expected
I expect to be able to see
uid
field set in the fluentd log with the contents of the session variableuid
.Actual
I get an error message before the page loads:
Debugging
I use act-fluent-logger-rails 0.1.7 in production with no problem.
I used
git bisect
to find the commit that introduced this error to be: 286f5eeI think the problem is that after this commit, log_tags get evaluated too early. Here is part of the output of my
bundle exec rake middleware
:I think log_tags get evaluated at the Rails::Rack::Logger level, but this is before the session is loaded (in the CookieStore level). If I comment out the
request.session[:uid]
from log_tags, then there is no error.I think before 286f5ee, (1) the logger saves the request object, and (2) log_tags get evaluated when the logger calls
flush
. This way, it evaluates it later after the session is loaded.How can we resolve this error?
The text was updated successfully, but these errors were encountered: