Combined with New Relic Logs, logs in context makes it easy to link to your log data with related data across the rest of the New Relic platform. For example, you can easily correlate log messages to a related error trace or distributed trace in APM. This is accomplished by appending trace IDs to the corresponding application logs then automatically filtering to these logs from the errors or distributed trace UIs. Bringing all of this data together in a single tool allows a user to quickly get to the root cause of an issue -- narrowing down from all of your logs, to finding the exact log lines that you need to identify and resolve a problem.
New Relic’s logs in context feature gives users the ability to see logs associated with various objects in the New Relic UI:
- APM errors
- APM traces and spans
- Kubernetes containers
The following diagram shows the lifecycle of a log message, from enrichment with agent metadata (contextual logging), to formatting and forwarding the log data to New Relic Logs:
Compatibility and requirements
Access to logs in context requires a New Relic APM Pro or Pro trial subscription and enabling of distributed tracing. Before enabling distributed tracing, read the transition guide to learn about the effects on existing APM features and set-up recommendations.
To configure APM logs in context for New Relic Logs, ensure your configuration meets the following requirements:
- New Relic Logs enabled, with a compatible log forwarding plugin installed.
- Ability to update to a supported version of the APM agent, and ability to enable distributed tracing for your agent:
Configure APM logs in context for New Relic Logs
Before you get started, here is an overview of the steps to configure APM logs in context:
- Confirm that you have New Relic Logs enabled, with a compatible log forwarding plugin installed to send your application logs to New Relic.
- Install or update your APM agent, including enabling distributed tracing, as needed.
- Install a logging extension to annotate your application log files with logs in context metadata. If there's not an extension you can use, you can create a logging extension using APIs.
- Configure your logging to use the extension or plug-in.
- Confirm it's working by following the guidance for your agent language, but in general:
- when you view your logs, you can see logs in context metadata, and then,
- you can view this metadata using the New Relic Logs UI.
Choose your APM agent to see specific instructions on how to configure APM logs in context for your agent language:
|Agent||Supported logging framework|
For information on creating your own logging extension, see logs in context API calls.
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, charts, or alerts.