le0pard/mongodb_logger

Messages node is empty

dimonzozo opened this issue · 5 comments

Added mongodb_logger to existing application based on Rails 3.2.6. Everything seems working fine but messages node is empty for each logged messaged. Do you have any ideas, why it could happen?

Thanks.

Hello, @dimonzozo. I don't understand what you mean by "messages node". Can you show me the screenshot or give detailed description?

Hi, @le0pard.

This is example of JSON stored in MongoDB

{ 
  "_id" : ObjectId("4fe20a99d0156d24a400000f"), 
  "method" : "GET", 
  "action" : "show", 
  "controller" : "photo", 
  "path" : "/photo/334", 
  "url" : "http://example.ru/photo/334", 
  "params" : { "action" : "show", "controller" : "photo", "id" : "334" }, 
  "ip" : "90.100.04.100", 
  "messages" : { }, 
  "request_time" : ISODate("2012-06-20T17:38:33.364Z"), 
  "application_name" : "PhotoStorage", 
  "runtime" : 23 
}

Messages node is empty, but I expected to see some details inside of it. I mean details that usually show up in log file, like:

Processing by PhotoController#show as HTML
Parameters: {"id"=>"336"}
Rendered photo/_upload.html.erb (0.3ms)
Rendered photo/show.html.haml within layouts/application (4.6ms)
Rendered news/_sidebar.html.haml (0.2ms)

Or executed SQL queries as shown on this screenshot.

May be I'm wrong and this node suited for something else. Please correct me if it's so.

Also, I noticed that logs is not being written to log file anymore, regardless of disable_file_logging set to false

Oh, I understand. To see SQL or rendering info you need in "config/needed_enviroment.rb" set needed log level. To see all information about SQL, rendering and etc. you need set log level to debug. Here some info:

http://guides.rubyonrails.org/debugging_rails_applications.html

In production log level info, in development and test - debug.

Thanks for quick response.

I already have log_level set in my config/environments/production.rb to

config.log_level = :debug

But messages still not show up.

Please take a look at this code.

    def initialize(options={})
      path = options[:path] || File.join(Rails.root, "log/#{Rails.env}.log")
      level = options[:level] || DEBUG
      internal_initialize
    rescue => e
      # should use a config block for this
      Rails.env.production? ? (raise e) : (puts "MongodbLogger WARNING: Using BufferedLogger due to exception: " + e.message)
    ensure
      if disable_file_logging?
        @level          = level
        @buffer         = {}
        @auto_flushing  = 1
        @guard          = Mutex.new
      else
        super(path, level)
      end
    end

I think I guess why the problem could be.
@level is not being set unless disable_file_logging?