Skip to content

Instantly share code, notes, and snippets.

@cbergau
Created March 19, 2019 22:15
Show Gist options
  • Save cbergau/96d59bf721e7b0c3d0ccfd4f5a607290 to your computer and use it in GitHub Desktop.
Save cbergau/96d59bf721e7b0c3d0ccfd4f5a607290 to your computer and use it in GitHub Desktop.
log4j2.xml for Graylog2
<Configuration packages="biz.paluch.logging.gelf.log4j2">
<Appenders>
<Gelf name="gelf" host="udp:192.168.99.100" port="12201" version="1.1" extractStackTrace="true"
filterStackTrace="true" mdcProfiling="true" includeFullMdc="true" maximumMessageSize="8192"
originHost="%host{fqdn}" additionalFieldTypes="request=String">
<Field name="timestamp" pattern="%d{dd MMM yyyy HH:mm:ss,SSS}" />
<Field name="level" pattern="%level" />
<Field name="simpleClassName" pattern="%C{1}" />
<Field name="className" pattern="%C" />
<Field name="server" pattern="%host" />
<Field name="Facility" pattern="spring-boot-5-service" />
<Field name="server.fqdn" pattern="%host{fqdn}" />
<!-- This is a static field -->
<Field name="fieldName2" literal="fieldValue2" />
<!-- This is a field using MDC -->
<Field name="mdcField2" mdc="mdcField2" />
<DynamicMdcFields regex="mdc.*" />
<DynamicMdcFields regex="(mdc|MDC)fields" />
</Gelf>
</Appenders>
<Loggers>
<Root level="INFO">
<AppenderRef ref="gelf" />
</Root>
</Loggers>
</Configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment