New Relic Logs in Context
What you'll learn: How to automatically correlate application logs with APM traces and infrastructure metrics using New Relic's logs-in-context feature.
Why Logs in Context Matter
Imagine debugging a slow API request. You see the trace in APM, but switching to a separate logging tool to find relevant logs breaks your flow. You're hunting for timestamps, request IDs, and guessing which log lines matter. Logs in context eliminates this friction by automatically linking logs directly to traces and infrastructure metrics in a single view.
How It Works
New Relic's logs-in-context feature enriches your application logs with tracing metadata (trace IDs, span IDs) at the point of logging. When you configure your application's logging library with New Relic's instrumentation:
- Automatic enrichment: The APM agent injects trace and span identifiers into your log statements
- Unified forwarding: Logs flow to New Relic alongside APM data
- Correlation: New Relic links logs to specific transactions, errors, and infrastructure hosts
Implementation Pattern
When using New Relic APM agents (Java, .NET, Node.js, etc.), you configure your existing logging framework (like Logback or Winston) with a New Relic formatter. This formatter adds fields like trace.id and span.id to each log entry. You can then forward logs using the agent itself or external shippers like Fluentd.
The result: click on an APM trace, and see only the logs from that specific request. Click on an infrastructure host, and see logs from that machine alongside CPU and memory metrics.
The Observability Triangle Complete
This bridges the gap between metrics (Prometheus/Grafana), traces (APM), and logs (centralized logging). Instead of three separate tools, you get correlated data streams that answer "what happened" (logs), "where's the bottleneck" (traces), and "what's the system state" (metrics) in one interface.
Key Takeaway: New Relic logs-in-context automatically enriches application logs with trace metadata, enabling seamless correlation between logs, APM traces, and infrastructure metrics without manual searching or log parsing.