With our Node.js APM agent, you can get logs in context, which lets you see your app logs in the context of your other New Relic data. For general information on this feature, see APM logs in context.
With application logging, your APM agent automatically collects and contextualizes your logs.
If you are using a supported framework, you have three options to configure APM logs in context to send your app's logs and linking metadata automatically to New Relic.
Supported frameworks for automatic logs in context include:
If you're not using a supported framework, you may instead use the agent's log forwarding API method to perform your own instrumentation. For details, see the Node.js agent API docs.
Agent releases 8.16.0 and higher have this feature enabled in the agent configuration file by default.
Agent log forwarding will cause an increase in the consumption of data when a supported framework is detected. The amount depends on the application and amount of logs it produces. This feature can be disabled. See Disable automatic logging for more information about your options.
If you already have a log forwarding solution in place, you should disable this feature.
While you wait for your data to come in...
Did this doc help you install?
Your logs may include sensitive information protected by HIPAA or other compliance protocols. By default we obfuscate number patterns that appear to be for items such as credit cards or Social Security numbers, but you may need to hash or mask additional information.
For more information, see our documentation about obfuscation expressions and rules. You can hash or mask your log data by using the New Relic UI or by using NerdGraph, our GraphQL API.
To make the most of your logging data:
- On the APM Summary page, click your Web transaction time chart to view logs associated with a specific point in time.
- Check your app's Errors inbox to view the logs associated with your errors.
- Use distributed tracing to see the logs associated with individual traces.
- Explore more logging data across your platform with our Logs UI.
- Set up alerts based on log output and severity.
- Query your data using our specialized UI for logs data, and create dashboards with the results.
Typically your logs will start to appear less than a minute after you enable APM logs in context. Check your app's Triage > Logs section. You will also start seeing log patterns related to the error there.
If you don't see any logs for errors or traces, there may not be any for your app. Try refreshing the UI page, or change the selected time period.
APM logs in context automatically forwards APM agent log data. It is enabled by default. If you do enable application logging, it can have a negative impact on your security, compliance, billing, or system performance. For more information, or if you need to adjust the default setting, follow the procedures to disable automatic logging.
To enable logs in context for APM apps monitored by Node.js, you can use our manual installation option.
- Make sure you have already set up logging in New Relic. This includes configuring a supported log forwarder that collects your application logs and extends the metadata that is forwarded to New Relic.
- Install or update to the latest Node.js agent version, and enable distributed tracing. Use Node.js agent version 6.2.0 or higher for logs in context.
- Install a supported framework to enrich your log data, or directly use the agent's log forwarding API.
- In your agent configuration, set
false. (Otherwise, the agent will automatically instrument your logger and calling these enrichers yourself will do nothing.)
- Configure logs in context for Node.js using the appropriate log extension.
- To verify that you have configured the log appender correctly, run your application, then check your logs data in New Relic using the query operator
If everything is configured correctly and your data is being forwarded to New Relic with the enriched metadata, your logs should now be emitted as JSON and contain
span.id fields. If you don't see log data in the UI, follow the troubleshooting procedures. If you'd like to see a working example of logs in context, take a look at our example application.
After you set up APM logs in context, make the most of your logging data:
- Explore the logging data across your platform with our Logs UI.
- See your logs in context of your app's performance in the APM UI. Troubleshoot errors with distributed tracing, stack traces, application logs, and more.
- Get deeper visibility into both your application and your platform performance data by forwarding your logs with our infrastructure monitoring agent. Review your infrastructure logs in the UI.
- Set up alerts.
- Query your data and create dashboards.