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:
- Enable log monitoring with a compatible log forwarding plugin.
- Install or update the Node.js agent.
- Configure the Winston extension.
- 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:
To install the New Relic Winston log enricher, enter the following command into your terminal or command line interface:
npm install @newrelic/winston-enricherIn your application code, update your logging configuration to add the
newrelicFormatter
as shown below:// index.jsrequire('newrelic')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'}),newrelicFormatter())
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:
- Includes
trace.id
andspan.id
fields - 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
.
Troubleshooting
Problem
Not all log data in a message or for a specific attribute is being displayed.
Cause
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:
- Explore your data using the Logs UI.
- Troubleshoot errors with distributed tracing, stack traces, application logs, and more.
- Query your data and create custom dashboards or alerts.
その他のヘルプ
さらに支援が必要な場合は、これらのサポートと学習リソースを確認してください:
- Explorers Hubでは、コミュニティからのサポートを受けたり、ディスカッションに参加したりすることができます。
- 当社サイトで答えを見つけて、サポートポータルの使用方法を確認してください。
- Linux、Windows、およびmacOS向けトラブルシューティングツールであるNew Relic Diagnosticsを実行してください。
- New Relicのデータセキュリティとライセンスドキュメント をご確認ください。