A platform for community discussion. Free, open, simple.
DEV: Remove noise from `Rails::Rack::Logger` after Rails 7.1 upgrade (#27731)
Alan Guo Xiang Tan5ca2c8b8ac6b
diff --git a/config/initializers/101-lograge.rb b/config/initializers/101-lograge.rbindex 5eaedb5b207..c42d9cb3c8a 100644--- a/config/initializers/101-lograge.rb+++ b/config/initializers/101-lograge.rb@@ -13,6 +13,11 @@ Rails.application.config.to_prepare doRails.application.configure doconfig.lograge.enabled = true+ # Monkey patch Rails::Rack::Logger#logger to silence its logs.+ # The `lograge` gem is supposed to do this but it broke after we upgraded to Rails 7.1.+ # This patch is a temporary workaround until we find a proper fix.+ Rails::Rack::Logger.prepend(Module.new { def logger = (@logger ||= Logger.new(IO::NULL)) })+Lograge.ignore(lambda do |event|# this is our hijack magic status,