- log4j 1.x must be configured and working in the application.
- log4j must be configured in code or via XML. Properties files are not supported because
AsyncAppenderinstances can only be automatically configured via XML. - You must be using at least version 5.6.0 of the Java Agent.
There are some changes to your application to use the New Relic log4j 1.x Extension. All steps are required.
Optional: Configuration Options for setting max stack size or collecting MDC.
Refer to Maven Central for the appropriate snippets.
Update your logging configuration xml like the example below.
<appender name="TypicalFile" class="org.apache.log4j.FileAppender">
<param name="file" value="logs/log4j1-app.log"/>
<param name="append" value="false"/>
<layout class="com.newrelic.logging.log4j1.NewRelicLayout"/> <!-- only this line needs to be added -->
</appender>Why? The New Relic log format is a tailored JSON format with specific fields in specific places that our log forwarder plugins and back end rely on. At this time, we don't support any customization of that format.
Update your logging configuration XML like the example below.
<appender name="NewRelicFile" class="com.newrelic.logging.log4j1.NewRelicAsyncAppender">
<appender-ref ref="TypicalFile" />
</appender>Why? The New Relic log format includes New Relic-specific data that must be captured on the thread the log message
is coming from. This appender captures that information before passing to the standard AsyncAppender logic.