When using ActiveRecord one can see all SQL queries executed when page is being loaded. How to achieve the same with Mongoid 5?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.