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

Ability to disable logging

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.0.2
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      It is not currently possible to disable logging on the ruby mongo driver when using Mongoid. Disabling the logger in the config block does not work:

      Mongoid.configure do |config|
      config.from_hash(settings[ENVIRONMENT])
      config.logger = nil
      end

      nor does just setting Mongoid.logger to nil. The ruby mongo driver continues to output the warning:
      "MongoDB logging. Please note that logging negatively impacts performance and should be disabled for high-performance production apps"

      It is desirable to turn off logging completely in production, not set to a logger with a low priority. The fundamental problem appears to be the is the logger method in mongoid/config.rb:

      def logger
      @logger ||= defined?(Rails) ? Rails.logger : ::Logger.new($stdout)
      end

      The ||= is causing a logger set to nil to always be set to a new logger. Ideally Mongoid would disable logging on the ruby driver by default making it explicit to enable if needed. The performance penalty of enabling logging is generally undesirable.

            Assignee:
            Unassigned Unassigned
            Reporter:
            pdlug Paul Dlug
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: