-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Using the ruby configuration DSL, setting a logger instance has no effect on a replica set connection. I imagine this is due to the odd nature of initiating a replica set connection at the driver level, but nonetheless, we needed a logger and had to jump through some hoops to set one. I ended up doing the following in an initializer:
Mongoid.configure do |config| cfg = YAML.load_file(File.expand_path('../../../config/mongoid.yml', __FILE__))[Rails.env] cfg.merge!(:logger => Logger.new($stdout)) config.from_hash(cfg) end
I imagine this ends up making two connections to the database?
It would be nice to be able to use this syntax:
Mongoid.configure do |config| config.logger = Logger.new($stdout) end