Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1158

Cannot set a logger on a replica set connection

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.3.1
    • 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
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            ajsharp Alex Sharp
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: