New Relic offers extensions for log monitoring that are compatible with current versions of Spring and Spring Boot. If you use Spring, read on to learn how to enable New Relic's logs in context and start receiving log data in New Relic.
If you already know the logging library, you can skip directly to that documentation:
Compatibility and requirements
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.