iamolegga / nestjs-pino

Platform agnostic logger for NestJS based on Pino with REQUEST CONTEXT IN EVERY LOG
MIT License
1.26k stars 98 forks source link

Multi-stream with stdout and datadog #748

Closed tuliomir closed 2 years ago

tuliomir commented 2 years ago

[X] I've read the docs of nestjs-pino

[X] I've read the docs of pino

[X] I couldn't find the same question about nestjs-pino

Question I'm trying to implement a setup where my NestJS application logs all the http requests on the std-out with trace level via pino-http and, when the application actively requests a log that is level info or higher, send a copy of the log to a datadog transport. Not the "agent" kind of interaction, but the one that actually makes a http request for each log to the Datadog API.

I have tried many different implementations for this, read the pino documentation, tried writing my own writeStream and even tried using the existing pino-datadog library via their api interface. All without success.

I can't identify I'm failing at some basic understanding of NestJS/Pino or if I'm actually facing some bug that I can't understand.

Could someone please point me in a general direction on how to implement this? Maybe a similar project on a public github repo could prove useful.

I'm used to have winston handle multiple transports at once, even with local file on some occasions. Not sure if this is the way to think the solution on PinoJS.

Thanks in advance.

Please mention other relevant information such as Node.js version and Operating System. I'm using NodeJS 14.15.1 with NestJS 7.6.15, nestjs-pino 2.4.0, pino-http 6.4.0 and pino-datadog 2.0.2

iamolegga commented 2 years ago

This question is not about the current module but about pino configuration. This module just passes all the configuration to the underlying pino-http, so I'm closing this issue. I suggest to try implement this logic with http-pino first and ask this question in appropriate module

ajfranzoia commented 2 years ago

@iamolegga you point towards the pino-http direction, while the creators of that package say that this is internally supported pino now, https://github.com/pinojs/pino-http/issues/245#event-7407765140. Can we have any clear answer on this? Thanks