pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.21k stars 874 forks source link

Question: Is it possible to send to default STDOUT _and_ to another transport? #1741

Closed muya closed 1 year ago

muya commented 1 year ago

Hello. I'm trying to configure pino as follows:

However, it seems that enabling pino-sentry-transport disables the STDOUT logging.

How can one configure so that both work?

Note: this is in a production setting (inside a Docker container), so I'd rather not use pino-pretty for STDOUT

I think the approach would be to have some sort of "stdout transport", but I don't know how to configure this together with the pino-sentry-transport.

muya commented 1 year ago

The solution is to use pino/file, with destination set to 1:

Example below is based on Fastify, sending logs to both stdout & Sentry (for error and above)

const transportTargets: TransportTargetOptions[] = [
    {
      target: 'pino/file',
      options: {
        destination: 1
      },
      level: 'info'
    },
    {
      target: 'pino-sentry-transport',
      options: {
        sentry: {
          dsn: 'https://some/sentry/url'
        },
        minLevel: 40
      },
      level: 'info'
    }
  ]

const logger = {
    level: config.logLevel,
    transport: {
      targets: transportTargets
    }
  }

// Pass this logger to the fastify instance

const server: FastifyInstance = Fastify({logger: logger})

// continue with Fastify setup.
github-actions[bot] commented 1 year ago

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.