• /
  • Log in
  • Free account

APM logs in context

When you're troubleshooting an issue in your app or host, you need all the New Relic tools at your fingertips. But you don't want to do a lot of context switching across the UI or be overwhelmed by the wealth of information available.

Our APM agents can automatically add relevant attributes to your application log data. This makes using logs in context extremely easy. Applications can also use the agent to forward log data directly to New Relic.

Logs are more valuable in the context of the application, transaction, or error they belong to. Using our logs in context functionality will change the way you troubleshoot by giving you visibility of logs from your applications, distributed traces, and errors directly in APM.

To see how logs in context can help you find the root cause of an issue in your apps and hosts, watch this short video (approx. 3:40 minutes):

Learn more about the power of automatic logs in context. The example describes how an engineering team used it to troubleshoot their app's poor response time and rising error rates.

Get started

To set up APM logs in context:

  1. If you don't have one already, create a New Relic account. It's free, forever.
  2. Update to the supported agent version for your apps and hosts.
  3. Enable logs for your agent, and make a few small updates to the configuration file.

That's it! Start troubleshooting your applications with APM logs in context in New Relic:

Screenshot of APM Summary page with logs in context options

Drill down into your logs, traces, and errors, all from the APM Summary page in New Relic.

APM agent log configuration

Our latest APM agents support automatically adding context and forwarding logs without the need to install or maintain third-party software! Your logs will automatically include attributes such as span.id, trace.id, hostname, entity.guid, entity.name, and more. This metadata links your logs to traces, spans, infrastructure data, and other telemetry, making it easier to troubleshoot.

Not every language or logging framework is supported yet. The following are our currently supported environments, with links to language-specific documentation:

Tip

APM logs in context automatically forwards APM agent log data and is enabled by default. This 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.

If your APM agent doesn't support our automatic logs in context solution yet, you can continue to use our manual logs in context solutions, and forward your logs via our infrastructure agent or supported third-party forwarder.

Ensure data privacy

Caution

You control what log data is sent to New Relic, so be sure to follow your organization's security guidelines to mask, obfuscate, or prevent sending personal identifiable information (PII), protected health information (PHI), or any other sensitive data.

Our log ingest pipeline automatically masks credit cards, Social Security numbers, national IDs, etc. For more information, see our security documentation for log management.

You can also create custom rules to mask or hash sensitive data in your logs with our obfuscation feature. This is critical when it is impractical or impossible to restrict access to sensitive data, or when some data should never be stored by New Relic. Read our obfuscation documentation to find out more.

Prevent duplicate logs

Using logs in context functionality will increase your data ingest. Depending on your account's pricing model, this may have an impact on your ingest limits and billing.

Caution

If you want to use the APM agent to send logs directly from your applications, you must disable or modify log forwarding solutions that are currently collecting logs from those applications. Otherwise you will be sending duplicate logs, which will result in double billing.

Check our upgrade guide to learn more about how you can avoid sending duplicate logs.

For more information, follow the procedures to disable your specific log forwarder.

Manage your ingest limits

Example: Your engineering team is troubleshooting a problem with your app, so you temporarily increase the volume of logs collected by the APM agent to provide more granular logging. However, if you leave higher limits running for several days, this could lead to sending unnecessary data that will increase your bill.

To avoid any surprises, we recommend that you use NRQL queries to create alert conditions to keep track of your ingest limits. For example:

Example: The power of logs in context

Here is a detailed use case of using APM logs in context to get to the root cause of a problem.

Example scenario: The on-call engineer receives a New Relic alert notification about poor response time and rising error rates for their app. They need to discover the root cause behind the increase in errors and latency, so they can decide whether to rotate a problematic host out of load balancing or to roll back the most recent release.

To start troubleshooting, they go to the New Relic UI.

Create issueEdit page
Copyright © 2022 New Relic Inc.