Middleware that logs errors to MongoDB
$ npm install git://github.com/alvinl/mongo-logger.git
The following example will log errors to a collection named errors
and each doc. will expire after 30 days.
var mongoLogger = require('mongo-logger'),
app = express();
app.use(mongoLogger({ uri: 'mongodb://localhost:27017/errorDb',
collection: 'errors',
expire: '30d' }));
uri
(Required) MongoDB uri to connect to.collection
The collection name to save the logs to. (Defaults toerrors
)expire
TTL to set to the logs. If not set, the logs will never expire.
The following is what a log document consists of
timeStamp
Timestamp of when the log was saved, also used for expiring logs.message
The error message (Error.message
)stack
The error stack (Error.stack
)user
The clients ipmethod
The http method (ex.GET
)path
The url path where the error came fromheaders
The headers of the clienterrName
The type of error (Error
,TypeError
, etc)