I set the mongoose debug to true.
mongoose.set('debug', true)
But now the debug log is printing in console.I need to specify a separate file for mongoose debug so that I can check the queries if needed.How can I do that?
the great aaron heckmann answered this in Logging outbound queries
mongoose.set('debug', function (collectionName, method, query, doc [, options]) {
//save to file what you need
});
Well, you would probably have to open a filehandle and write the error to that file.
But for a short-cut, what I do is capture all output of console and log it to a file when I start my app:
node app.js 1>$APP_DIR/log/app.log 2>&1 &
Then you can tail the log file:
tail -f ./log/app.log