• /
  • Log in
  • Free account

Node.js: Configure with Winston

Use our Winston extension to link your log data with related data across the rest of the New Relic platform. Read on to learn how to configure logs in context and enrich your log data.

Compatibility and requirements

To use New Relic logs in context with Winston, ensure your configuration meets the following requirements:

Configure logs in context with log monitoring

To configure logs in context with Winston:

  1. Enable log monitoring with a compatible log forwarding plugin.
  2. Install or update the Node.js agent.
  3. Configure the Winston extension.
  4. Check for logging data.

Enable log monitoring

Confirm that you have log monitoring enabled, with a compatible log forwarding plugin installed to send your application logs to New Relic.

Install or update the Node.js agent

Install or update to the most recent Node.js agent version, and enable Distributed tracing.

Configure the Winston extension

To configure logs in context with the Winston extension, complete the following steps:

  1. To install the New Relic Winston log enricher, enter the following command into your terminal or command line interface:

    npm install @newrelic/winston-enricher
  2. In your application code, update your logging configuration to add the newrelicFormatter as shown below:

    // index.js
    const newrelicFormatter = require('@newrelic/winston-enricher')

    The New Relic formatter can be used individually or combined with other formatters as the final format.

    format: winston.format.combine(
    winston.format.label({label: 'test'}),

Check for logging data

To verify that you have configured the extension correctly, run your application and verify that the logging you have configured contains the following:

  1. Includes trace.id and span.id fields
  2. Is properly-formatted JSON lines

If everything is configured correctly and your data is being reported, you should see data logs in the New Relic Logs UI using the query operator has: span.id/trace.id.



Not all log data in a message or for a specific attribute is being displayed.


The stack trace will be written to the error.stack property. To accommodate the 4000 character log line limit for New Relic Logs, the stack and trace properties will be removed and the message, error.message and error.stack values will be truncated to 1024 characters.

What's next?

Now that you've set up APM logs in context, here are some potential next steps:

For more help

If you need more help, check out these support and learning resources:

Create issueEdit page
Copyright © 2021 New Relic Inc.