How not to trim Mongoid logs?

This is how Mongoid logs operations:

D, [2016-01-12T18:42:19.790639 #7906] DEBUG -- : MONGODB | localhost:27017 | app_test.update | STARTED | {"update"=>"users", "updates"=>[{"q"=>{"_id"=>BSON::ObjectId('5695652bc54d2d1ee200001e')}, "u"=>{"$addToSet"=>{"favorite_ids"=>{"$each"=>[BSON::ObjectId('5695652bc54d2d1ee200001f')]}}}, "multi"=>false, "upsert"=>false}], "writeConcern"=>{:w=>1}, "orde... 

I want to see the full log message. Is it possible?

Obs: I am using Mongoid 5 .

+7
ruby ruby-on-rails mongoid
source share
2 answers

After digging in the Mongo Ruby Driver (which is used by Mongoid> = 5), I found a solution:

 Mongo::Monitoring::CommandLogSubscriber::LOG_STRING_LIMIT = 1_000 

Edit

The correct way to do this is to add the truncate_logs parameter to the mongoid.yml file:

config /mongoid.yml:

 development: clients: default: database: database_name_development hosts: - localhost:27017 options: truncate_logs: false 

-

Honestly, Mongoid has at least bad documentation

+10
source share

The Mongoid cuts logs, so you should check your Mongo logs. Here's how:

  • First ps aux | grep mongod ps aux | grep mongod

  • If you specified a log file, you will find the --logpath option on your mongod instance.

  • If you do not find something like this mongod --profile=1 --slowms=1 --config /usr/local/etc/mongod.conf

  • cat /usr/local/etc/mongod.conf to find something like the following

    systemLog: destination: file path: /usr/local/var/log/mongodb/mongo.log logAppend: true

  • Then tail -f /usr/local/var/log/mongodb/mongo.log

This way, you can view full non-truncated logs.

If you cannot see the debug logs, go into mongo , select your database, and then db.setLogLevel(number) , where number is between 1 and 5.

More on db.setLogLevel()

+1
source share

All Articles