【发布时间】:2018-01-15 18:51:06
【问题描述】:
我正在使用 winston、expressWinston、winston-mongoDB 来管理我的 NodeJs 应用程序中的日志。
在使用带有 express-winston 的 winston-mongodb 传输时;我可以按以下格式将日志存储到我的 mongoDB 集合中。 (元:真)
{
"_id" : ObjectId("5a124f9781d911337ebeb98d"),
"timestamp" : ISODate("2017-11-20T03:44:23.336Z"),
"level" : "info",
"message" : "GET /stylesheets/bootstrap.css 304 2ms",
"meta" : {
"res" : {
"statusCode" : 304
},
"req" : {
"url" : "/stylesheets/bootstrap.css",
"headers" : {
"host" : "localhost:3000",
"connection" : "keep-alive",
},
"method" : "GET",
"httpVersion" : "1.1",
"originalUrl" : "/stylesheets/bootstrap.css",
"query" : {}
},
"responseTime" : 2
}
我可以在元数据中获取请求/响应信息。
这些细节有可能直接成为收藏的一部分吗? ,类似这样:
{
"_id" : ObjectId("5a12537d81b6b634cb7d4696"),
"timestamp" : ISODate("2017-11-20T04:01:01.229Z"),
"level" : "info",
"message" : "GET /stylesheets/bootstrap.css 304 11ms",
"status": 200,
"requestUrl": '/',
"requestMethod": 'GET',
"remoteIp": '::1'
"meta" : {}
}
【问题讨论】:
-
我在使用相同的实现时遇到了一些问题,您能在这里查看我的问题stackoverflow.com/questions/48202738/… 吗?希望能对此有所帮助。
标签: node.js mongodb express winston