Package com.github.loki4j.logback
Class Loki4jAppender
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
- com.github.loki4j.logback.Loki4jAppender
-
- All Implemented Interfaces:
ch.qos.logback.core.Appender<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.ContextAware,ch.qos.logback.core.spi.FilterAttachable<ch.qos.logback.classic.spi.ILoggingEvent>,ch.qos.logback.core.spi.LifeCycle
public class Loki4jAppender extends ch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>Main appender that provides functionality for sending log record batches to Loki.
-
-
Field Summary
Fields Modifier and Type Field Description longmaxRetryBackoffMsMaximum backoff delay before the next attempt to re-send a failed batch.intmaxRetryJitterMsUpper bound for a jitter added to the retry delays.longminRetryBackoffMsInitial backoff delay before the next attempt to re-send a failed batch.
-
Constructor Summary
Constructors Constructor Description Loki4jAppender()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidappend(ch.qos.logback.classic.spi.ILoggingEvent event)voidsetBatchMaxBytes(int batchMaxBytes)voidsetBatchMaxItems(int batchMaxItems)voidsetBatchTimeoutMs(long batchTimeoutMs)voidsetDrainOnStop(boolean drainOnStop)voidsetDropRateLimitedBatches(boolean dropRateLimitedBatches)voidsetFormat(Loki4jEncoder encoder)"format" instead of "encoder" in the name allows to specify the default implementation, so users don't have to write full-qualified class name by default.voidsetHttp(HttpSender sender)"http" instead of "sender" is just to have a more clear name for the configuration section.voidsetInternalQueuesCheckTimeoutMs(long internalQueuesCheckTimeoutMs)voidsetMaxRetries(int maxRetries)voidsetMaxRetryBackoffMs(long maxRetryBackoffMs)voidsetMaxRetryJitterMs(int maxRetryJitterMs)voidsetMetricsEnabled(boolean metricsEnabled)voidsetMinRetryBackoffMs(long minRetryBackoffMs)voidsetRetryTimeoutMs(long retryTimeoutMs)voidsetSendQueueMaxBytes(long sendQueueMaxBytes)voidsetUseDirectBuffers(boolean useDirectBuffers)voidsetVerbose(boolean verbose)voidstart()voidstop()-
Methods inherited from class ch.qos.logback.core.UnsynchronizedAppenderBase
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, setName, toString
-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
-
-
-
Field Detail
-
minRetryBackoffMs
public long minRetryBackoffMs
Initial backoff delay before the next attempt to re-send a failed batch. Batches are retried with an exponential backoff (e.g. 0.5s, 1s, 2s, 4s, etc.) and jitter.
-
maxRetryBackoffMs
public long maxRetryBackoffMs
Maximum backoff delay before the next attempt to re-send a failed batch.
-
maxRetryJitterMs
public int maxRetryJitterMs
Upper bound for a jitter added to the retry delays.
-
-
Method Detail
-
start
public void start()
- Specified by:
startin interfacech.qos.logback.core.spi.LifeCycle- Overrides:
startin classch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
stop
public void stop()
- Specified by:
stopin interfacech.qos.logback.core.spi.LifeCycle- Overrides:
stopin classch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
append
protected void append(ch.qos.logback.classic.spi.ILoggingEvent event)
- Specified by:
appendin classch.qos.logback.core.UnsynchronizedAppenderBase<ch.qos.logback.classic.spi.ILoggingEvent>
-
setBatchMaxItems
public void setBatchMaxItems(int batchMaxItems)
-
setBatchMaxBytes
public void setBatchMaxBytes(int batchMaxBytes)
-
setBatchTimeoutMs
public void setBatchTimeoutMs(long batchTimeoutMs)
-
setSendQueueMaxBytes
public void setSendQueueMaxBytes(long sendQueueMaxBytes)
-
setMaxRetries
public void setMaxRetries(int maxRetries)
-
setMinRetryBackoffMs
public void setMinRetryBackoffMs(long minRetryBackoffMs)
-
setMaxRetryBackoffMs
public void setMaxRetryBackoffMs(long maxRetryBackoffMs)
-
setMaxRetryJitterMs
public void setMaxRetryJitterMs(int maxRetryJitterMs)
-
setDropRateLimitedBatches
public void setDropRateLimitedBatches(boolean dropRateLimitedBatches)
-
setRetryTimeoutMs
public void setRetryTimeoutMs(long retryTimeoutMs)
-
setFormat
public void setFormat(Loki4jEncoder encoder)
"format" instead of "encoder" in the name allows to specify the default implementation, so users don't have to write full-qualified class name by default.
-
setHttp
public void setHttp(HttpSender sender)
"http" instead of "sender" is just to have a more clear name for the configuration section.
-
setVerbose
public void setVerbose(boolean verbose)
-
setMetricsEnabled
public void setMetricsEnabled(boolean metricsEnabled)
-
setDrainOnStop
public void setDrainOnStop(boolean drainOnStop)
-
setUseDirectBuffers
public void setUseDirectBuffers(boolean useDirectBuffers)
-
setInternalQueuesCheckTimeoutMs
public void setInternalQueuesCheckTimeoutMs(long internalQueuesCheckTimeoutMs)
-
-