NestJS 中的 HTTP Pino 记录器和 Elastic Common Schema (ecs) 格式
HTTP Pino logger and Elastic Common Schema (ecs) format in NestJS
我正在尝试申请 @elastic/ecs-pino-format to nestjs-pino. Under the good nestjs-pino is using http-pino
. I have noticed that http-pino
adds the request object inside [Symbol(pino.chindings)]
and I am assuming it's using a child logger.So I tried to write a custom formatter for extracting the req by calling obj.res.log.bindings()
and putting at http.request
to be compliant with Elastic Common Schema (ecs). The problem I face is now my log contains duplicate the req
and the http.request
and can't find a way to remove it. Not sure if I am looking in the wrong direction but I have found a lot of issues trying to make nestjs-pino print Elastic Common Schema (ecs) format logs. Also I have noticed issues where @elastic/ecs-pino-format 无法处理 fastify。有没有人遇到过类似的问题?
所以我对 pino
和 pino-http
以及它们如何集成到 nesjs-pino. From the looks of it @elastic/ecs-pino-format doesn't handle all the specifics for Elastic Common Schema (ecs) in pino-http
. So what I ended up doing was passing in nestjs-pino
as a configuration a merge of the format object from @elastic/ecs-pino-format 和配置 pino-http
感到困惑。
pino-http
支持传递
customAttributeKeys: {
req: 'http.request',
res: 'http.response',
}
用于更改req
和res
的键。至于req
和res
包含的数据,http-pino
还有另一种转换方式
serializers: {
req: (log) => {... return transform },
res: (log) => {... return transform },
}
有关pino HTTP options的更多信息。
希望这可以帮助任何面临相同问题或想要 nestjs 的 Elastic Common Schema (ecs) 日志。
我正在尝试申请 @elastic/ecs-pino-format to nestjs-pino. Under the good nestjs-pino is using http-pino
. I have noticed that http-pino
adds the request object inside [Symbol(pino.chindings)]
and I am assuming it's using a child logger.So I tried to write a custom formatter for extracting the req by calling obj.res.log.bindings()
and putting at http.request
to be compliant with Elastic Common Schema (ecs). The problem I face is now my log contains duplicate the req
and the http.request
and can't find a way to remove it. Not sure if I am looking in the wrong direction but I have found a lot of issues trying to make nestjs-pino print Elastic Common Schema (ecs) format logs. Also I have noticed issues where @elastic/ecs-pino-format 无法处理 fastify。有没有人遇到过类似的问题?
所以我对 pino
和 pino-http
以及它们如何集成到 nesjs-pino. From the looks of it @elastic/ecs-pino-format doesn't handle all the specifics for Elastic Common Schema (ecs) in pino-http
. So what I ended up doing was passing in nestjs-pino
as a configuration a merge of the format object from @elastic/ecs-pino-format 和配置 pino-http
感到困惑。
pino-http
支持传递
customAttributeKeys: {
req: 'http.request',
res: 'http.response',
}
用于更改req
和res
的键。至于req
和res
包含的数据,http-pino
还有另一种转换方式
serializers: {
req: (log) => {... return transform },
res: (log) => {... return transform },
}
有关pino HTTP options的更多信息。
希望这可以帮助任何面临相同问题或想要 nestjs 的 Elastic Common Schema (ecs) 日志。