Skip to content
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

undefined method `reset' for #<ActiveSupport::Logger #151

Open
entropywtf opened this issue Dec 13, 2018 · 2 comments
Open

undefined method `reset' for #<ActiveSupport::Logger #151

entropywtf opened this issue Dec 13, 2018 · 2 comments

Comments

@entropywtf
Copy link

entropywtf commented Dec 13, 2018

Hi,
Following the documentation, I put Rails.logger.reset into config/puma.rb

On server start though, I get an error:

undefined method reset' for #ActiveSupport::Logger:0x00007f932cfdb148 6: from /Users/marina/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/puma-3.12.0/lib/puma/cluster.rb:137:in fork' (NoMethodError ( 5: from /Users/marina/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/puma-3.12.0/lib/puma/cluster.rb:137:in block (2 levels) in spawn_workers'
NoMethodErrorNoMethodError)`

Thanks and sorry if I'm missing something obvious here. KR

@entropywtf
Copy link
Author

After looking closer and going through merged PRs I found out that reset method was exposed and it is actually a feature, BUT:

If you run into this error, you still have Rails.logger not set to Logstash. If Logstash logging is conditional in your application, you better put Rails.logger.reset under a condition like if respond_to?(:reset) or if ENV['LOGSTASH_ENABLED'] like I did in my project.

I'd suggest to put this advice into a README.

Thanks!

@bv-ritesh
Copy link

bv-ritesh commented Mar 12, 2021

In case of multilogger, the instance does not respond to reset method.

logger.loggers.each { |_logger|
 _logger.respond_to?(:reset)
}

This will work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants