logback
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 |
facility | Name of the Facility | logstash-gelf |
mdcProfiling | Perform Profiling (Call-Duration) based on MDC Data. See MDC Profiling for details | false |
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.
Please note: If the debug
attribute of the configuration
element is not set to true
, internal appender errors are not shown.
Logback Configuration
logback.xml Example:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>
<configuration>
<contextName>test</contextName>
<jmxConfigurator/>
<appender name="gelf" class="biz.paluch.logging.gelf.logback.GelfLogbackAppender">
<host>udp:localhost</host>
<port>12201</port>
<version>1.0</version>
<facility>logstash-gelf</facility>
<extractStackTrace>true</extractStackTrace>
<filterStackTrace>true</filterStackTrace>
<includeLocation>true</includeLocation>
<mdcProfiling>true</mdcProfiling>
<timestampPattern>yyyy-MM-dd HH:mm:ss,SSS</timestampPattern>
<maximumMessageSize>8192</maximumMessageSize>
<additionalFields>fieldName1=fieldValue1,fieldName2=fieldValue2</additionalFields>
<additionalFieldTypes>fieldName1=String,fieldName2=Double,fieldName3=Long</additionalFieldTypes>
<mdcFields>mdcField1,mdcField2</mdcFields>
<dynamicMdcFields>myMdc.*,[a-z]+Field</dynamicMdcFields>
<dynamicMdcFieldTypes>my_field.*=String,business\..*\.field=double</dynamicMdcFieldTypes>
<includeFullMdc>true</includeFullMdc>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>INFO</level>
</filter>
</appender>
<root level="DEBUG">
<appender-ref ref="gelf" />
</root>
</configuration>