When you need to correlate log data with other telemetry data, enable logs in context in New Relic. Logs in context adds metadata that links your logs with related APM data, like errors or distributed traces, or your platform performance data from infrastructure monitoring logs in New Relic One.
By bringing all of your application and infrastructure data together in a single solution, you can get to the root cause of issues faster. Logs in context help you quickly see meaningful patterns and trends.
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:
This diagram illustrates the flow of log messages through New Relic.
Don't spend extra time trying to narrow down all your logs from different parts of your platform. Instead, enable logs in context to see the exact log lines you need to identify and resolve a problem.
The process to enable logs in context is basically the same, regardless of which APM agent you use to monitor your application:
- 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.
- Update to a supported APM agent version for your app, and enable distributed tracing.
- Configure logs in context for your APM agent or for your infrastructure monitoring agent.
- View your logs within the context of your apps or infrastructure in New Relic One.
The main differences in this procedure are which log appenders you can use to extend and enrich your log data, and how to configure the log appender you select for your APM agent.
For detailed information, see the logs-in-context procedures for:
If our logging solutions don't meet your needs, you can use other options to send your log data to New Relic:
- Logging extensions via agent API calls
- HTTP endpoint via our Log API
- Syslog protocols via TCP endpoint (useful for CDNs, hardware devices, or managed services)
Here is an example of logs in context for app trace details, visible in the APM UI.
After you set up logs in context for APM or infrastructuring monitoring, make the most of your logging data in the New Relic One UI:
- 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.