pino icon indicating copy to clipboard operation
pino copied to clipboard

Question: Transform entire log JSON format

Open dflor003 opened this issue 4 years ago • 1 comments

Hi! We're trying to leverage pino logger at a large enterprise with a very specific logging JSON format that needs to be sent to STDOUT and STDERR in order to be scraped by our PaaS system and processed by the ELK stack.

Looking through the docs, I see that you can use formatters to transform individual pieces of the logs. However, in our case, this would not be sufficient. Is there anything in the library outside of a custom transport that will allow us to transform the entire log message at once?

Here's a rough example of how our log message format needs to look:

{
  "applog": { // <- Our logs need to be nested under a specific root key
    "log_level": ...,
    "context": "...",
    "http_request": {
      ...
    },
    ...
  }
}

Any help would be appreciated. Thanks!

dflor003 avatar Nov 30 '21 16:11 dflor003

The best approach is to develop a custom transport that make it suit your needs, see https://getpino.io/#/docs/transports.

mcollina avatar Nov 30 '21 16:11 mcollina

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Feb 18 '23 00:02 github-actions[bot]