我很想知道可以winston
使用mongodb
将文档的对象ID返回到存储错误的集合中。我试图放置一个l.h.s变量,但它的赋值为undefined
。如果不是,我们怎么能实现这个目标呢?
winston = require('winston'),
mongod = require('winston-mongodb');
const moment = require('moment');
var logger = new winston.Logger({
level: 'debug',
timestamp: function () {
return moment().format('YYYY-MM-DD hh:mm:ss')
},
transports: [
new winston.transports.Console({
timestamp: function () {
return moment().format('YYYY-MM-DD hh:mm:ss')
}
}),
new winston.Logger({
level: 'debug',
transports: [
new(winston.transports.File)
({ filename: 'filepath' })
],
timestamp: function () {
return moment().format('YYYY-MM-DD hh:mm:ss')
}
}),
new(winston.transports.MongoDB)({
db : 'dbpath',
collection : 'Logs',
level : 'error',
capped : true,
timestamp: function () {
return moment().format('YYYY-MM-DD hh:mm:ss')
}
})
]
})
var objId = logger.error('error', 'Hello','5ad454648bef1f502db434dc', { req_id: "objid"});
console.log(objId);