reidmorrison/rails_semantic_logger

No such middleware to insert before: Rails::Rack::Logger

gregfletch opened this issue · 8 comments

Environment

Provide at least:

  • Ruby Version: 3.2.2
  • Rails Version: 7.1.1 (branch: '7-1-stable')
  • Semantic Logger Version: 4.15.0
  • Rails Semantic Logger Version: 4.13.0
  • Other Application/framework names and versions (e.g. Puma, etc.): Puma
  • Rails configuration. Only need the settings related to Rails Semantic Logger and Semantic Logger.
  • Full Stack Trace, if an exception is being raised.

Note:

Expected Behavior

RSpec should be able to run without unhandled errors coming rails_semantic_logger.

Actual Behavior

Error occurs immediately when attempting to run rspec after updating Rails Semantic Logger to 4.13.0 and Rails from v7.0 to v7.1.
Stack Trace:

RuntimeError:
  No such middleware to insert before: Rails::Rack::Logger
# /Users/user/.gem/ruby/3.2.2/bundler/gems/rails-c742674dccf3/actionpack/lib/action_dispatch/middleware/stack.rb:179:in `assert_index'
# /Users/user/.gem/ruby/3.2.2/bundler/gems/rails-c742674dccf3/actionpack/lib/action_dispatch/middleware/stack.rb:120:in `swap'
# /Users/user/.gem/ruby/3.2.2/gems/rails_semantic_logger-4.13.0/lib/rails_semantic_logger/engine.rb:38:in `block in <class:Engine>'
# /Users/user/.gem/ruby/3.2.2/bundler/gems/rails-c742674dccf3/railties/lib/rails/initializable.rb:32:in `instance_exec'
# /Users/user/.gem/ruby/3.2.2/bundler/gems/rails-c742674dccf3/railties/lib/rails/initializable.rb:32:in `run'
# /Users/user/.gem/ruby/3.2.2/bundler/gems/rails-c742674dccf3/railties/lib/rails/initializable.rb:61:in `block in run_initializers'
# /Users/user/.gem/ruby/3.2.2/bundler/gems/rails-c742674dccf3/railties/lib/rails/initializable.rb:50:in `each'
# /Users/user/.gem/ruby/3.2.2/bundler/gems/rails-c742674dccf3/railties/lib/rails/initializable.rb:50:in `tsort_each_child'
# /Users/user/.gem/ruby/3.2.2/bundler/gems/rails-c742674dccf3/railties/lib/rails/initializable.rb:60:in `run_initializers'
# /Users/user/.gem/ruby/3.2.2/bundler/gems/rails-c742674dccf3/railties/lib/rails/application.rb:423:in `initialize!'
# ./config/environment.rb:7:in `<top (required)>'
# /Users/user/.gem/ruby/3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /Users/user/.gem/ruby/3.2.2/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
# ./spec/rails_helper.rb:6:in `<top (required)>'
# /Users/user/.gem/ruby/3.2.2/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
# /Users/user/.gem/ruby/3.2.2/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'

Pull Request

  • Consider submitting a Pull Request with a fix for the issue.
    • This is particularly helpful when running newer Rails versions, since we are not running it yet.
  • Or, even a Pull request that only includes a test that reproduces the problem.

There was a community supplied PR submitted to switch to Rackup, want to give it a try with the new Rails Semantic Logger v4.14.0?

I've had the same error with v4.14.0

we also get this error with:
rails_semantic_logger (4.14.0)
semantic_logger (4.15.0)
rails (7.1.2)
rack (3.0.8)

No longer seeing this issue after updating to the latest version from the Rails '7-1-stable' branch and latest version of rails_semantic_logger.

Same issue here with rails 7.1.3.2

We are seeing this against a large monolith using Rails 6.1.7.6.

We are also seeing this issue:

  • ruby 3.1.4
  • rails 7.1.3.3
  • rails_semantic_logger 4.14.0
  • semantic_logger 4.15.0
  • rack 2.2.9

I face this issue during upgrade from ruby 2.7 to 3.0 without any changes to gem versions
After some back and forth realize that problem was in a different place.
in my case undef for method inside application controller did not work and error was silently suppressed.

rails 6.1.7
ruby 3.0
rails_semantic_logger 4.14.0
semantic_logger 4.15.0

I think it not related to semantic logger itself