Socket
Socket
Sign inDemoInstall

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

Package Overview
Dependencies
1
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

pino transport for newrelic log api


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

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

Last updated on 03 Nov 2023

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc