log4j 1.2.x
Following settings can be used:
Attribute Name | Description | Default |
---|---|---|
host | Hostname/IP-Address of the Logstash host. The host field accepts following forms:
|
none |
port | Port of the Logstash host | 12201 |
version | GELF Version 1.0 or 1.1 |
1.0 |
originHost | Originating Hostname | FQDN Hostname |
extractStackTrace | Send the Stack-Trace to the StackTrace field (true /false ) |
false |
filterStackTrace | Perform Stack-Trace filtering (true /false ) |
false |
includeLocation | Include source code location | true |
mdcProfiling | Perform Profiling (Call-Duration) based on MDC Data. See MDC Profiling for details | false |
facility | Name of the Facility | logstash-gelf |
threshold | Log-Level threshold | INFO |
filter | Class-Name of a Log-Filter | none |
additionalFields | Send additional static fields. The fields are specified as key-value pairs are comma-separated. Example: additionalFields=fieldName=Value,fieldName2=Value2 |
none |
additionalFieldTypes | Type specification for additional and MDC fields. Supported types: String , long , Long , double , Double and discover (default if not specified, discover field type on parseability). Eg. field=String,field2=double |
discover for all additional fields |
mdcFields | Send additional fields whose values are obtained from MDC. Name of the Fields are comma-separated. Example: mdcFields=Application,Version,SomeOtherFieldName |
none |
dynamicMdcFields | Dynamic MDC Fields allows you to extract MDC values based on one or more regular expressions. Multiple regexes are comma-separated. The name of the MDC entry is used as GELF field name. | none |
dynamicMdcFieldTypes | Pattern-based type specification for additional and MDC fields. Key-value pairs are comma-separated. Example: my_field.*=String,business\..*\.field=double |
none |
includeFullMdc | Include all fields from the MDC. | false |
maximumMessageSize | Maximum message size (in bytes). If the message size is exceeded, the appender will submit the message in multiple chunks. | 8192 |
timestampPattern | Date/time pattern for the Time field |
yyyy-MM-dd HH:mm:ss,SSS |
The only mandatory field is host
. All other fields are optional.
log4j Configuration
Properties:
log4j.appender.gelf=biz.paluch.logging.gelf.log4j.GelfLogAppender
log4j.appender.gelf.Threshold=INFO
log4j.appender.gelf.Host=udp:localhost
log4j.appender.gelf.Port=12201
log4j.appender.gelf.Version=1.0
log4j.appender.gelf.Facility=logstash-gelf
log4j.appender.gelf.ExtractStackTrace=true
log4j.appender.gelf.FilterStackTrace=true
log4j.appender.gelf.IncludeLocation=true
log4j.appender.gelf.MdcProfiling=true
log4j.appender.gelf.TimestampPattern=yyyy-MM-dd HH:mm:ss,SSS
log4j.appender.gelf.MaximumMessageSize=8192
log4j.appender.gelf.AdditionalFields=fieldName1=fieldValue1,fieldName2=fieldValue2
log4j.appender.gelf.AdditionalFieldTypes=fieldName1=String,fieldName2=Double,fieldName3=Long
log4j.appender.gelf.MdcFields=mdcField1,mdcField2
log4j.appender.gelf.DynamicMdcFields=mdc.*,(mdc|MDC)fields
log4j.appender.gelf.DynamicMdcFieldTypes=my_field.*=String,business\..*\.field=double
log4j.appender.gelf.IncludeFullMdc=true
XML:
<appender name="gelf" class="biz.paluch.logging.gelf.log4j.GelfLogAppender">
<param name="Threshold" value="INFO" />
<param name="Host" value="udp:localhost" />
<param name="Port" value="12201" />
<param name="Facility" value="logstash-gelf" />
<param name="ExtractStackTrace" value="true" />
<param name="FilterStackTrace" value="true" />
<param name="IncludeLocation" value="true" />
<param name="MdcProfiling" value="true" />
<param name="TimestampPattern" value="yyyy-MM-dd HH:mm:ss,SSS" />
<param name="MaximumMessageSize" value="8192" />
<param name="AdditionalFields" value="fieldName1=fieldValue1,fieldName2=fieldValue2" />
<param name="AdditionalFieldTypes" value="fieldName1=String,fieldName2=Double,fieldName3=Long" />
<param name="MdcFields" value="mdcField1,mdcField2" />
<param name="DynamicMdcFields" value="mdc.*,(mdc|MDC)fields" />
<param name="DynamicMdcFieldTypes" value="my_field.*=String,business\..*\.field=double" />
<param name="IncludeFullMdc" value="true" />
</appender>