Conversation

AbhiPrasad

ref #15952

resolves #16622

This PR adds the ability to send logs to sentry via a pino transport.

Usage

import pino from 'pino';

const logger = pino({
  transport: {
    target: '@sentry/pino-transport',
    options: {
      // Optional: filter which log levels to send to Sentry
      levels: ['error', 'fatal'], // defaults to all levels
    },
  },
});

// Now your logs will be sent to Sentry
logger.info('This is an info message');
logger.error('This is an error message');

Options

logLevels

Type: Array<'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'>

Default: ['trace', 'debug', 'info', 'warn', 'error', 'fatal'] (all levels)

Use this option to filter which log levels should be sent to Sentry.

const transport = pino.transport({
  target: '@sentry/pino-transport',
  options: {
    levels: ['warn', 'error', 'fatal'], // Only send warnings and above
  },
});

Next

I need to write some integration tests - this is being tracked by #16624

@AbhiPrasadAbhiPrasad self-assigned this Jun 20, 2025
@AbhiPrasadAbhiPrasad force-pushed the abhi-pino-logs-impl branch from 4661a26 to ad39866 Compare June 20, 2025 15:54
| error | 50 | error |
| fatal | 60 | fatal |

### Custom Levels Support
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still undecided about this behaviour.

See https://getpino.io/#/docs/api?id=opt-customlevels for details about pino custom levels.

What does everyone think?

@AbhiPrasadAbhiPrasad marked this pull request as ready for review June 20, 2025 15:58
@AbhiPrasadAbhiPrasad requested review from a team, Lms24 and s1gr1d and removed request for a team June 20, 2025 15:58
Sign up for free to join this conversation on . Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

Implement logs pino support via pino-abstract-transport
@AbhiPrasad