Erik
Erik

Reputation: 14750

log all requests in mongodb

I have a nodejs-express-mongoose application and I want to set logging system up. I know about connect.logger() middleware but I want to log into MongoDB database.

Can I achieve that by using overriding connect.logger() middleware of are some express plugins for my purposes?

Upvotes: 1

Views: 1832

Answers (1)

aaronheckmann
aaronheckmann

Reputation: 10780

mongoose has a debug option that logs all collection method invocations (update, insert, find, ensureIndex, etc) with console.error. you may also override it with your own custom function:

mongoose.set('debug', true) // for logging with console.error
mongoose.set('debug', yourFunction) // to handle it yourself

Upvotes: 3

Related Questions