Socket
Book a DemoInstallSign in
Socket

@harusame0616/pino-newrelic-log-api-transport

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@harusame0616/pino-newrelic-log-api-transport

pino transport for newrelic log api

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

pino-newrelic-log-api-transport

A Pino v7+ transport to send log to newrelic with Logs API.

Caution

newrelic has an automatic log forwarding feature.
Consider using the official nodejs agent.
https://docs.newrelic.com/jp/docs/apm/agents/nodejs-agent/installation-configuration/install-nodejs-agent

If for some reason you cannot use the automatic log forwarding feature with nodejs agent, please use it.

Installation

pnpm  @harusame0616/pino-newrelic-log-api-transport

Usage

import pino from 'pino';
import {
  NewrelicLogAPITransportOption,
  endpointEnum,
} from '@harusame0616/pino-newrelic-log-api-transport';

const options: NewrelicLogAPITransportOption = {
  // licenseKey: <YOUR_LICENSE_KEY> or set NEWRELIC_LICENSE_KEY in environment variables
  endpoint: endpointEnum.us,
};

const logger = pino({
  messageKey: 'message',
  errorKey: 'error',
  level: 'info',
  base: {
    entity: {
      // your app name
      name: process.env.NEWRELIC_APP_NAME,
    },
  },
  formatters: {
    level: (label) => ({ level: label }),
  },
  transport: {
    target: '@harusame0616/pino-newrelic-log-api-transport',
    options: options,
  },
});

logger.info('info level log');

※ If you are using the nextjs app router you may need to add "pino" to serverComponentsExternalPackages in next.config.

https://github.com/vercel/next.js/discussions/46987#discussioncomment-6986115

and run bellow

NEWRELIC_LICENSE_KEY=YOUR_LICENSE NEWRELIC_APP_NAME=YOUR_APP_NAME node YOUR_APP

FAQs

Package last updated on 03 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts