Open alextsui05 opened 7 years ago
@alextsui05
Hi
If you put rails 4.2.x ver 0.4.0, you will encounter the bug. I am sorry, please use ver.0.1.7 as it is once.
Investigate the bug and fix it.
Thank you very much!
Hi, I am having the same issue with rails 5. How could we fix this issue @ryosuke-endo ?
@miguelperez
Thanks!
Hi, I am having the same issue with rails 5.
Which version occurred in Rails 5?
How could we fix this issue
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. Just saying that I'm looking into this.
I think we need to add a middleware to this gem for now to ensure we have the request object available. Then, in a major version upgrade, I'd like to get rid of the Thread.current stuff plus the middleware we are adding and start using config.log_tags.
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: 286f5eeea9b8ee12a1bb0ce4352697a2655cddecI 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 286f5eeea9b8ee12a1bb0ce4352697a2655cddec, (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?