New Relic offers extensions for New Relic Logs that are compatible with current versions of Spring and Spring Boot. If you use Spring, this document will help you enable New Relic's logs in context and start receiving log data in New Relic.
The goal of this document is to help you figure out what logging library you're using, so that you can configure it to enable New Relic's logs in context. If you already know the logging library, you can skip directly to that documentation:
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 use New Relic logs in context with Logback, ensure your configuration meets the following requirements:
With Spring Boot
The extensions support default configurations only on Spring Boot 2.0 and higher.
For users of Spring Boot, here are tips for determining which logging library you have:
- If you have
spring-boot-starter-log4j2in your dependencies, you're using log4j 2.x. Refer to the Spring Boot log4j 2.x documentation for basic configuration, and the New Relic log4j 2 extension for customizing configuration for New Relic Logs.
- If you're using Spring Boot but not the starter-log4j2, you're using logback by default. Refer to Spring Boot logback documentation for basic configuration, and the New Relic logback extension for customizing it for New Relic Logs.
With Spring (but not Spring Boot)
Spring 5 or higher:
- Spring implements a bridge to other logging libraries that will automatically find them. However, those individual libraries must be configured and explicitly included in your project dependencies. Consult your Gradle, Maven, or other build tool's dependency tree to identify your logging dependency. Then visit the individual library page for more information.
Spring 4 or lower:
- Spring version 4 and lower uses Apache Commons Logging for its bridge. Refer to the Spring documentation for information on configuring its bridge.