15

This is how the Mongoid log the 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 be able to see the full log message. Is that possible?

Obs: I'm using Mongoid 5.

2 Answers 2

22

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

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

Edit

The proper way to do this is add truncate_logs option to mongoid.yml file:

config/mongoid.yml:

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

--

Mongoid has a poor documentation

Sign up to request clarification or add additional context in comments.

3 Comments

This option in yml seems to be a null attempt :(
Which mongoid version are your using? Check out this: github.com/mongodb/mongoid/blob/…
I tried to disable truncation via this setting but was unsuccessful. After debugging more I realized that the query was already truncated by the time it was passed to Mongo::Monitoring::CommandLogSubscriber. Any ideas how to untruncate further up the chain?
0

Mongoid truncates the logs so you should check your mongo logs. Here is how:

  • First ps aux | grep mongod

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

  • If not you will 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 un-truncated logs.

If you can not see debug logs then login to mongo, choose your database and then db.setLogLevel(number) where number is between 1 to 5.

Read more about db.setLogLevel()

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.