| Strategy | Description |
|---|---|
| preferPrimary | (default)
The first destination is considered the primary destination.
Each additional destination is considered a secondary destination.
This strategy prefers the primary destination, unless it is down.
The appender will attempt to connect to each destination in the order in which they are configured.
If a connection attempt fails, thes the appender will attempt to connect to the next destination.
If a connection succeeds, and then closes before the minConnectionTimeBeforePrimary
has elapsed, then the appender will attempt to connect to the next destination.
If a connection succeeds, and then closes after the minConnectionTimeBeforePrimary
has elapsed, then the appender will attempt to connect
to the destinations in the order in which they are configured,
starting at the first/primary destination.
The secondaryConnectionTTL can be set to gracefully close connections to secondary destinations after a specific duration. This will force the the appender to reattempt to connect to the destinations in order again. The secondaryConnectionTTL value does not affect connections to the primary destination. The minConnectionTimeBeforePrimary (10 seconds by default) specifies the minimum amount of time that a sucessfully established connection must remain open before the next connection attempt will try the primary. i.e. If a connection stays open less than this amount of time, then the next connection attempt will attempt the next destination (instead of the primary). This is used to prevent a connection storm to the primary in the case the primary accepts a connection, and then immediately closes it. Example:
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>destination1.domain.com:4560</destination>
<destination>destination2.domain.com:4560</destination>
<destination>destination3.domain.com:4560</destination>
<connectionStrategy>
<preferPrimary>
<secondaryConnectionTTL>5 minutes</secondaryConnectionTTL>
</preferPrimary>
</connectionStrategy>
</appender>
|
| roundRobin |
This strategy attempts connections to the destination in round robin order.
If a connection fails, the next destination is attempted.
The connectionTTL can be set to gracefully close connections after a specific duration. This will force the the appender to reattempt to connect to the next destination. Example:
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>destination1.domain.com:4560</destination>
<destination>destination2.domain.com:4560</destination>
<destination>destination3.domain.com:4560</destination>
<connectionStrategy>
<roundRobin>
<connectionTTL>5 minutes</connectionTTL>
</roundRobin>
</connectionStrategy>
</appender>
|
| random |
This strategy attempts connections to the destination in a random order.
If a connection fails, the next random destination is attempted.
The connectionTTL can be set to gracefully close connections after a specific duration. This will force the the appender to reattempt to connect to the next random destination. Example:
<appender name="stash" class="net.logstash.logback.appender.LogstashTcpSocketAppender">
<destination>destination1.domain.com:4560</destination>
<destination>destination2.domain.com:4560</destination>
<destination>destination3.domain.com:4560</destination>
<connectionStrategy>
<random>
<connectionTTL>5 minutes</connectionTTL>
</random>
</connectionStrategy>
</appender>
|
| Wait Strategy | Parameters | Implementation |
|---|---|---|
| blocking | none | BlockingWaitStrategy |
| busySpin | none | BusySpinWaitStrategy |
| liteBlocking | none | LiteBlockingWaitStrategy |
| yielding | none | YieldingWaitStrategy |
sleeping{
retries,
sleepTimeNs
}
e.g.sleeping or sleeping{500,1000} |
|
SleepingWaitStrategy |
phasedBackoff{
spinTime,
yieldTime,
timeUnit,
fallbackStrategy
}
e.g.phasedBackoff{10,60,seconds,blocking} |
|
PhasedBackoffWaitStrategy |
timeoutBlocking{
timeout,
timeUnit
}
e.g.timeoutBlocking{1,minutes} |
|
TimeoutBlockingWaitStrategy |
liteTimeoutBlocking{
timeout,
timeUnit
}
e.g.liteTimeoutBlocking{1,minutes} |
|
LiteTimeoutBlockingWaitStrategy |
| Provider | Description/Properties |
|---|---|
| context | Outputs entries from logback's context.
|
| nestedField |
Nests a JSON object under the configured fieldName. The nested object is populated by other providers added to this provider. See Nested JSON provider.
|
| pattern |
Outputs fields from a configured JSON Object string, while substituting patterns supported by logback's PatternLayout.
|
| sequence |
Event sequence number. With Logback 1.3+ the sequence number is obtained from the event itself as long as the LoggerContext is configured with a `SequenceNumberGenerator` (which is not by default). If no SequenceNumberGenerator is configured, the provider emits a warning and reverts to a locally generated incrementing number starting at 1.
|
| threadName | Name of the thread from which the event was logged.
|
| timestamp | Event timestamp.
|
| uuid |
Outputs random UUID as field value. Handy when you want to provide unique identifier for log lines.
Note: The com.fasterxml.uuid:java-uuid-generator optional dependency must be added to applications that use the `uuid` provider. |
| version | Logstash JSON format version.
|
| Provider | Description/Properties |
|---|---|
| arguments |
Outputs fields from the event arguments array. See Event-specific Custom Fields.
|
| callerData | Outputs data about from where the logger was called (class/method/file/line).
|
| contextName | Outputs the name of logback's context.
|
| loggerName | Name of the logger that logged the message.
|
| logLevel | Logger level text (INFO, WARN, etc).
|
| logLevelValue | Logger level numerical value.
|
| logstashMarkers | Used to output Logstash Markers as specified in Event-specific Custom Fields. |
| mdc |
Outputs entries from the Mapped Diagnostic Context (MDC). Will include all entries by default. When key names are specified for inclusion, then all other fields will be excluded. When key names are specified for exclusion, then all other fields will be included. It is a configuration error to specify both included and excluded key names.
|
| keyValuePairs |
Outputs key value pairs added via slf4j's fluent api. Will include all key value pairs by default. When key names are specified for inclusion, then all other keys will be excluded. When key names are specified for exclusion, then all other keys will be included. It is a configuration error to specify both included and excluded key names.
|
| message | Formatted log event message.
|
| rawMessage | Raw log event message, as opposed to formatted log where parameters are resolved.
|
| rootStackTraceElement | (Only if a throwable was logged) Outputs a JSON Object containing the class and method name from which the outer-most exception was thrown.
|
| stackHash | (Only if a throwable was logged) Computes and outputs a hexadecimal hash of the throwable stack. This helps identifying several occurrences of the same error (more info).
|
| stackTrace | Stacktrace of any throwable logged with the event. Stackframes are separated by newline chars.
|
| tags | Outputs logback markers as a comma separated list.
|
| throwableClassName | (Only if a throwable was logged) Outputs a field that contains the class name of the thrown Throwable.
|
| throwableMessage | (Only if a throwable was logged) Outputs a field that contains the message of the thrown Throwable.
|
| throwableRootCauseClassName | (Only if a throwable was logged and a root cause could be determined) Outputs a field that contains the class name of the root cause of the thrown Throwable.
|
| throwableRootCauseMessage | (Only if a throwable was logged and a root cause could be determined) Outputs a field that contains the message of the root cause of the thrown Throwable.
|
| Provider | Description/Properties |
|---|---|
| contentLength | Content length.
|
| elapsedTime | Elapsed time in milliseconds.
|
| message | Message in the form `${remoteHost} - ${remoteUser} [${timestamp}] "${requestUrl}" ${statusCode} ${contentLength}`.
|
| method | HTTP method.
|
| protocol | HTTP protocol.
|
| remoteHost | Remote Host.
|
| remoteUser | Remote User.
|
| requestedUri | Requested URI.
|
| requestedUrl | Requested URL.
|
| requestHeaders | Include the request headers.
|
| responseHeaders | Include the response headers.
|
| statusCode | HTTP status code.
|