Max Filippov
Max Filippov

Reputation: 2072

How to log all request to rails console in Mongoid 5?

When using ActiveRecord one can see all SQL queries executed when page is being loaded. How to achieve the same with Mongoid 5?

Upvotes: 5

Views: 4543

Answers (1)

Simone Carletti
Simone Carletti

Reputation: 176352

You can customize Mongoid logging level as described in the documentation. You can also configure it in the main Rails application.

module MyApplication
  class Application < Rails::Application
    config.mongoid.logger = Logger.new($stdout, :warn)
  end
end

If you want to reuse the same Rails logger, simply assign Rails.logger (just make sure to assign it after the Rails.logger is initialized.

Upvotes: 5

Related Questions