Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongoose can't stop query logging

I recently updated to Mongoose 4, and now mongoose logs all of my queries in this format:

Mongoose: repostevents.find({ day: { '$gt': new Date("Sun, 13 Nov 2016 22:16:22 GMT") }, completed: false, userID: 143155925 }, { fields: undefined })

I want to turn off these logs.

I have tried the recommended solutions:

mongoose.set('debug', false);

and

mongoose.set('debug', function(collectionName, method, query, doc) {});

which change nothing.

These log messages are getting really annoying because I run large batch queries on my database which floods my log files with useless query logs.

like image 209
Christian Ayscue Avatar asked Apr 29 '26 14:04

Christian Ayscue


2 Answers

JohnnyHK was correct in his comment. After doing a search, I found that there were several locations where another developer had written:

mongoose.set('debug',true);

I should have asked the other developer or done a full project search.

like image 113
Christian Ayscue Avatar answered May 01 '26 04:05

Christian Ayscue


I could not turn off the logs. Although I used the command to search:

grep -ri "goose.set" ~/

Command showed all the references, wiping them it unfortunately did not help in my case.

like image 23
Egeniy Ostrovskiy Avatar answered May 01 '26 03:05

Egeniy Ostrovskiy