Skip to content

Instantly share code, notes, and snippets.



Last active Feb 12, 2020
What would you like to do?
Sample log4j2.xml that adds the lines needed to enable New Relic Logs in Context for Log4J v2.x.
This is a full example showing the one line you need to add to log4j2.xml to enable New Relic Logs in Context.
Most of this file is stock - the only changes needed are shown below, flagged with comments.
<?xml version="1.0" encoding="UTF-8"?>
<Configuration xmlns=""
<!-- New Relic Logs in Context - Add NR Log4J extension -->
<Console name="STDOUT" target="SYSTEM_OUT">
<!-- New Relic Logs in Context - Enable the NR layout -->
<JsonLayout compact="true" eventEol="true">
<KeyValuePair key="" value="$${ctx:traceId}"/>
<KeyValuePair key="" value="$${ctx:spanId}"/>
<KeyValuePair key="" value="$${ctx:traceSampled}"/>
<KeyValuePair key="time" value="$${date:yyyy-MM-dd}T$${date:HH:mm:ss.SSS}Z"/>
<Logger name="io.grpc.netty" level="INFO"/>
<Logger name="io.netty" level="INFO"/>
<Logger name="" level="INFO"/>
<Root level="TRACE">
<AppenderRef ref="STDOUT"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.