Package io.dropwizard.logging.common
Class AbstractAppenderFactory<E extends ch.qos.logback.core.spi.DeferredProcessingAware>
- java.lang.Object
-
- io.dropwizard.logging.common.AbstractAppenderFactory<E>
-
- All Implemented Interfaces:
Discoverable
,AppenderFactory<E>
- Direct Known Subclasses:
AbstractOutputStreamAppenderFactory
,SyslogAppenderFactory
public abstract class AbstractAppenderFactory<E extends ch.qos.logback.core.spi.DeferredProcessingAware> extends Object implements AppenderFactory<E>
A base implementation ofAppenderFactory
. Configuration Parameters:Name Default Description threshold
ALL The minimum event level the appender will handle. logFormat
(none) An appender-specific log format. timeZone
UTC
The time zone to which event timestamps will be converted. Ignored if logFormat is supplied. queueSize
AsyncAppenderBase
The maximum capacity of the blocking queue. includeCallerData
AsyncAppenderBase
Whether to include caller data, required for line numbers. Beware, is considered expensive. discardingThreshold
AsyncAppenderBase
By default, when the blocking queue has 20% capacity remaining, it will drop events of level TRACE, DEBUG and INFO, keeping only events of level WARN and ERROR. To keep all events, set discardingThreshold to 0. messageRate
Maximum message rate: average duration between messages. Extra messages are discarded. This setting avoids flooding a paid logging service by accident. For example, a duration of 100ms allows for a maximum of 10 messages per second and 30s would mean 1 message every 30 seconds. The maximum acceptable duration is 1 minute. By default, this duration is not set and this feature is disabled. filterFactories
(none) A list of filters
to apply to the appender, in order, after thethreshold
.
-
-
Constructor Summary
Constructors Constructor Description AbstractAppenderFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ch.qos.logback.core.LayoutBase<E>
buildLayout(ch.qos.logback.classic.LoggerContext context, LayoutFactory<E> defaultLayoutFactory)
int
getDiscardingThreshold()
List<FilterFactory<E>>
getFilterFactories()
@Nullable DiscoverableLayoutFactory<?>
getLayout()
@Nullable String
getLogFormat()
@Nullable Duration
getMessageRate()
Returns the duration required between logged messages.int
getQueueSize()
String
getThreshold()
TimeZone
getTimeZone()
boolean
isIncludeCallerData()
void
setDiscardingThreshold(int discardingThreshold)
void
setFilterFactories(List<FilterFactory<E>> appenders)
void
setIncludeCallerData(boolean includeCallerData)
void
setLayout(@Nullable DiscoverableLayoutFactory<E> layout)
void
setLogFormat(@Nullable String logFormat)
void
setMessageRate(Duration messageRate)
Sets the time period required between logged messages.void
setNeverBlock(boolean neverBlock)
void
setQueueSize(int queueSize)
void
setThreshold(String threshold)
void
setTimeZone(String zoneId)
void
setTimeZone(TimeZone timeZone)
protected ch.qos.logback.core.Appender<E>
wrapAsync(ch.qos.logback.core.Appender<E> appender, AsyncAppenderFactory<E> asyncAppenderFactory)
protected ch.qos.logback.core.Appender<E>
wrapAsync(ch.qos.logback.core.Appender<E> appender, AsyncAppenderFactory<E> asyncAppenderFactory, ch.qos.logback.core.Context context)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.dropwizard.logging.common.AppenderFactory
build
-
-
-
-
Field Detail
-
threshold
@NotNull protected @NotNull ch.qos.logback.classic.Level threshold
-
logFormat
protected @Nullable String logFormat
-
layout
@Valid protected @Nullable @Valid DiscoverableLayoutFactory<E extends ch.qos.logback.core.spi.DeferredProcessingAware> layout
-
timeZone
@NotNull protected @NotNull TimeZone timeZone
-
-
Method Detail
-
getQueueSize
public int getQueueSize()
-
setQueueSize
public void setQueueSize(int queueSize)
-
getDiscardingThreshold
public int getDiscardingThreshold()
-
setDiscardingThreshold
public void setDiscardingThreshold(int discardingThreshold)
-
getMessageRate
public @Nullable Duration getMessageRate()
Returns the duration required between logged messages. Messages logged more frequently than this will be dropped. Anull
value means there is no rate limit.- Since:
- 2.0
-
setMessageRate
public void setMessageRate(Duration messageRate)
Sets the time period required between logged messages. Messages logged more frequently than this will be dropped. Anull
value disables the rate limit.- Since:
- 2.0
-
getThreshold
public String getThreshold()
-
setThreshold
public void setThreshold(String threshold)
-
getLogFormat
public @Nullable String getLogFormat()
-
setLogFormat
public void setLogFormat(@Nullable String logFormat)
-
getTimeZone
public TimeZone getTimeZone()
-
setTimeZone
public void setTimeZone(String zoneId)
-
setTimeZone
public void setTimeZone(TimeZone timeZone)
-
isIncludeCallerData
public boolean isIncludeCallerData()
-
setIncludeCallerData
public void setIncludeCallerData(boolean includeCallerData)
-
getFilterFactories
public List<FilterFactory<E>> getFilterFactories()
-
setFilterFactories
public void setFilterFactories(List<FilterFactory<E>> appenders)
-
setNeverBlock
public void setNeverBlock(boolean neverBlock)
-
getLayout
public @Nullable DiscoverableLayoutFactory<?> getLayout()
-
setLayout
public void setLayout(@Nullable DiscoverableLayoutFactory<E> layout)
-
wrapAsync
protected ch.qos.logback.core.Appender<E> wrapAsync(ch.qos.logback.core.Appender<E> appender, AsyncAppenderFactory<E> asyncAppenderFactory)
-
wrapAsync
protected ch.qos.logback.core.Appender<E> wrapAsync(ch.qos.logback.core.Appender<E> appender, AsyncAppenderFactory<E> asyncAppenderFactory, ch.qos.logback.core.Context context)
-
buildLayout
protected ch.qos.logback.core.LayoutBase<E> buildLayout(ch.qos.logback.classic.LoggerContext context, LayoutFactory<E> defaultLayoutFactory)
-
-