I'm using winston, expressWinston, winston-mongoDB to manage the logs in my NodeJs application.
While using winston-mongodb transport with express-winston; i can store the logs to my mongoDB collection in the following format. (meta:true)
{
"_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
}
I can get the request/response info in the meta.
Is it possible that these details be a part of the collection directly ? , something like this:
{
"_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" : {}
}