Star us on GitHub
Star
Menu

Logging in Pino.js

Learn how to set up highlight.io log ingestion for Pino.JS.
1
Set up your frontend highlight.io integration.

First, make sure you've followed the frontend getting started guide.

2
Install the relevant Highlight SDK(s).

Install @highlight-run/node, @highlight-run/pino with your package manager.

npm install --save @highlight-run/node @highlight-run/pino
Copy
3
Setup the Pino HTTP transport.

The Pino HTTP transport will send JSON logs to highlight.io. Make sure to set the project and service query string parameters.

const highlightConfig = { projectID: '<YOUR_PROJECT_ID>', serviceName: 'my-pino-logger', serviceVersion: 'git-sha', } as NodeOptions const pinoConfig = { level: 'debug', transport: { target: '@highlight-run/pino', options: highlightConfig, }, } as LoggerOptions if ( typeof process.env.NEXT_RUNTIME === 'undefined' || process.env.NEXT_RUNTIME === 'nodejs' ) { const { H } = require('@highlight-run/node') H.init(highlightConfig) } import type { LoggerOptions } from 'pino' import pino from 'pino' import type { NodeOptions } from '@highlight-run/node' const logger = pino(pinoConfig) logger.info({ key: 'my-value' }, 'hello, highlight.io!')
Copy
4
Verify your backend logs are being recorded.

Visit the highlight logs portal and check that backend logs are coming in.