activerecord-session_store: NoMethodError: undefined method silence for Logger after 2.0.0 upgrade
I’m attempting to upgrade to 2.0.0 to resolve the CVE, but I’m getting a bunch of exceptions like:
NoMethodError:
undefined method `silence' for #<Logger:0x0000555d12a49218>
in my test suite. I see the note in the README about logging, but I’m not doing anything fancy with the Rails logger nor do I seem to be able to find ActiveRecord::SessionStore::Extension::LoggerSilencer
in the codebase anymore.
Could this be related to some of the underlying dependencies?
- activerecord-session_store (1.1.3)
- actionpack (>= 4.0)
- activerecord (>= 4.0)
+ activerecord-session_store (2.0.0)
+ actionpack (>= 5.2.4.1)
+ activerecord (>= 5.2.4.1)
multi_json (~> 1.11, >= 1.11.2)
- rack (>= 1.5.2, < 3)
- railties (>= 4.0)
+ rack (>= 2.0.8, < 3)
+ railties (>= 5.2.4.1)
Ruby 2.7.2 Rails 6.1.2.1
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 21 (3 by maintainers)
Commits related to this issue
- Send include ActiveSupport::LoggerSilence instead of ActiveRecord::SessionStore::Extension::LoggerSilencer (see rails/activerecord-session_store#176) — committed to sosol/sosol by ryanfb 3 years ago
- Include ActiveSupport::LoggerSilence After upgrading activerecord-session_store we hit a problem with our logging (see https://github.com/rails/activerecord-session_store/issues/176 for more details)... — committed to alphagov/transition by thomasleese 3 years ago
- fix logger error: Puma caught this error: undefined method 'silence' for #<Logger. (see https://github.com/rails/activerecord-session_store/issues/176) — committed to excid3/sponsor-hub by deleted user 3 years ago
If anyone else is having this issue, I forked the project and added
ActiveRecord::SessionStore::Extension::LoggerSilencer
back in to version 2.0.0 with the CVE fix.That fork is located here: https://github.com/egallup02360/activerecord-session_store
Can confirm my logging works through GELF/Lograge->Graylog and the session IDs are properly secured with this fork. Obviously we would want to continue with the official repo at some point if a workaround or solution is found for this particular issue.
@jeremyburks-sikich Thanks for the pointer, that was the problem in my case! ❤️
I ran into the same issue.
ActiveRecord::SessionStore::Extension::LoggerSilencer
was removed in this commitI replaced my use of
ActiveRecord::SessionStore::Extension::LoggerSilencer
with the following.That’s fair, and I’m going to find my own way around this, I do appreciate your responses and suggestions. I’d just like to point out that prior to upgrading this gem, and only this gem, that logging worked perfectly for my use case.
This is just my opinion, but ripping an extension out that is documented in your README without a prior release that includes a depreciation warning is bad practice. Rails, in general, is really good about doing this, why is activerecord-session_store any different?
I understand patching the CVE was urgent, but that could have been fixed in a minor release rather than introducing almost two years worth of undocumented changes, since your last release, all at once. Again, just my opinion.
Thank you for your continued work on this project and I hope my opinions don’t offend you or come off as rude, that’s not my intention at all. We’re on Github for collaboration and sharing our opinions, after all.
@powerwlsl Maybe compare
staging.rb
toproduction.rb
and see if you can isolate any differences. Not sure though, I only was having trouble in my test environment.Not sure it helps but I have these logging related lines in my
staging
andproduction
environment configs:In my case, I removed the
config.logger = Logger.new(nil)
setting in my test environment and that solved the issue without addRails.logger.class.include ActiveSupport::LoggerSilence
.You could put it in your initializer:
config/initializers/session_store.rb
Thanks! That seemed to resolve things for me as well. I’m curious if this should be pulled into this gem directly? Feels weird to require changes to logging in consuming applications.