Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Exception when setting config.logger = in Rails 4 #10789

davidbalbert opened this Issue · 5 comments

4 participants


On Rails 4.0.0.rc1, if I set config.logger to be and make a request, I get an exception (backtrace included below). I've tested this at the tip of the 4-0-0 branch as well with the same results. Using works fine. I reproduced this on Mac OS X 10.8.3, with Ruby 2.0.0-p195 compiled with RVM.

It's not clear to me whether or not Ruby's Logger is supposed to work with Rails 4. The debugging guide still includes examples using the Logger class, and the Rails 4 release notes indicate that you should be able to use Logger as well. The upgrading guide doesn't mention Logger at all, though I know it is a work in progress.

On the other hand, core_ext/logger.rb in Active Support seems to be deprecated, though I am pretty sure that this file isn't being loaded by default in a new Rails 4 install.

At minimum, this seems like a documentation issue. If Ruby's Logger is no longer supported, the docs should probably say so, and examples using Logger should be changed.

If the stdlib logger is still supported, then I think this is a bug that probably needs to be fixed before 4.0 is released.

Please let me know if there's any way that I can be helpful.

ArgumentError (wrong number of arguments (0 for 1)):
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/activesupport/lib/active_support/core_ext/kernel/reporting.rb:82:in `capture'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/activerecord/lib/active_record/migration.rb:363:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/actionpack/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/activesupport/lib/active_support/callbacks.rb:373:in `_run__1084573524063806798__call__callbacks'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/activesupport/lib/active_support/callbacks.rb:80:in `run_callbacks'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/actionpack/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/actionpack/lib/action_dispatch/middleware/reloader.rb:64:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/actionpack/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/railties/lib/rails/rack/logger.rb:38:in `call_app'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/railties/lib/rails/rack/logger.rb:23:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/actionpack/lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/activesupport/lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/actionpack/lib/action_dispatch/middleware/static.rb:64:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/railties/lib/rails/engine.rb:511:in `call'
  /Users/david/.rvm/gems/ruby-2.0.0-p195@rails4/bundler/gems/rails-6f7046354719/railties/lib/rails/application.rb:97:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
  /Users/david/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
  /Users/david/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
  /Users/david/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

We're on rails 4.0.0.rc1 and ruby-2.0.0-p195 and config.logger = works when set in production.rb. However, in development, the above error is reproducible.


I can reproduce this issue.

In the edge and 4-0-stable, ::Logger doesn't include ::LoggerSilence, because we don't have require lib/active_support/core_ext/logger.rb.
Thus Kernel.silence is called.

If we don't support ::Logger, we should fix some document (@davidbalbert mentioned this in the description).
If we support ::Logger, ::LoggerSilence should be included .

Should we go to the either ?
/cc @tenderlove

@tenderlove tenderlove was assigned

We should support logger from stdlib. Silence is not thread safe. We can choose to synchronize during silence (which will block all other requests), or we can remove the silence usage.


Ok. I'm going to fix this . Maybe remove it :)

@kennyj kennyj closed this in 8ae73f1

I just verified this fix. Thanks very much!

@907th 907th referenced this issue from a commit
@907th 907th Fix #10856, #10789: `::Logger#silence` and `LoggerSilence` troubles
* Synchronization has been added to `LoggerSilence#silence`.

* Fix #10856: search pending migrations among all known migrations, not
  only the latest one. `ActiveRecord::Migrator.needs_migration?` works
  as expected now.

* Fix #10789: `LoggerSilence` included into `::Logger`.

* Revert 3970432: it is very bad idea to use mtime to check if
  there are pending migrations. Suppose you did `db:migrate/db:rollback`
  several times: checking will stop work at all (`db:migrate:status` has
  changed but mtime is not).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.