public abstract class AbstractAppender<WriterConfigType extends AbstractWriterConfig<WriterConfigType>,AppenderStatsType extends AbstractWriterStatistics,AppenderStatsMXBeanType,LogbackEventType>
extends ch.qos.logback.core.UnsynchronizedAppenderBase<LogbackEventType>
For the most part, appenders have the same behavior: they initialize, transform log messages, and shut down. Most of the code to do that lives here, with a few hooks that are implemented in the appender proper.
Most of the member variables defined by this class are protected. This is intended to support testing. If you decide to subclass and access those variables, remember that this is an internal class: they may go away.
Note: this appender is built on UnsynchronizedAppenderBase, which is
perhaps unnecessary (if you're worried about contention you shouldn't be doing a
lot of logging). However, there are some critical sections within append(LogbackEventType),
and these are protected by internal lock objects.
| Modifier and Type | Field and Description |
|---|---|
protected WriterConfigType |
appenderConfig |
protected AppenderStatsType |
appenderStats |
protected InternalLogger |
internalLogger |
protected ch.qos.logback.core.Layout<LogbackEventType> |
layout |
protected ThreadFactory |
threadFactory |
protected LogWriter |
writer |
protected WriterFactory<WriterConfigType,AppenderStatsType> |
writerFactory |
| Constructor and Description |
|---|
AbstractAppender(WriterConfigType appenderConfig,
ThreadFactory threadFactory,
WriterFactory<WriterConfigType,AppenderStatsType> writerFactory,
AppenderStatsType appenderStats,
Class<AppenderStatsMXBeanType> appenderStatsMXBeanClass) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
append(LogbackEventType event) |
protected abstract WriterConfigType |
generateWriterConfig()
Called as part of initialization.
|
AppenderStatsType |
getAppenderStatistics()
Returns the appender statistics object.
|
String |
getAssumedRole()
Returns the
assumedRole configuration property. |
long |
getBatchDelay()
Returns the
batchDelay configuration property. |
String |
getClientEndpoint()
Returns the
clientEndpoint configuration property. |
String |
getClientFactory()
Returns the
clientFactory configuration property. |
String |
getClientRegion()
Returns the
clientRegion configuration property. |
String |
getDiscardAction()
Returns the
discardAction configuration property. |
int |
getDiscardThreshold()
Returns the
discardThreshold configuration property. |
boolean |
getEnableBatchLogging()
Returns the
enableBatchLogging configuration property. |
long |
getInitializationTimeout()
Returns the
initializationTimeout configuration property. |
boolean |
getSynchronous()
Returns the
synchronous configuration property. |
boolean |
getTruncateOversizeMessages()
Returns the
truncateOversizeMessages configuration property. |
boolean |
getUseShutdownHook()
Returns the
useShutdownHook configuration property. |
protected void |
registerStatisticsBean()
Registers the appender statistics with JMX.
|
void |
setAssumedRole(String value)
Sets the
assumedRole configuration property. |
void |
setBatchDelay(long value)
Sets the
batchDelay configuration property. |
void |
setClientEndpoint(String value)
Sets the
clientEndpoint configuration property. |
void |
setClientFactory(String value)
Sets the
discardAction configuration property. |
void |
setClientRegion(String value)
Sets the
clientRegion configuration property. |
void |
setDiscardAction(String value)
Sets the
discardAction configuration property. |
void |
setDiscardThreshold(int value)
Sets the
discardThreshold configuration property. |
void |
setEnableBatchLogging(boolean value)
Sets the
enableBatchLogging configuration property. |
void |
setInitializationTimeout(long value)
Sets the
initializationTimeout configuration property. |
void |
setLayout(ch.qos.logback.core.Layout<LogbackEventType> layout)
Sets the layout manager for this appender.
|
void |
setName(String name) |
void |
setSynchronous(boolean value)
Sets the
synchronous configuration property. |
void |
setTruncateOversizeMessages(boolean value)
Sets the
truncateOversizeMessages configuration property. |
void |
setUseShutdownHook(boolean value)
Sets the
useShutdownHook configuration property. |
void |
start() |
void |
stop() |
protected void |
unregisterStatisticsBean()
Unregisters the appender statistics from JMX.
|
addFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, toStringaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextprotected ThreadFactory threadFactory
protected WriterFactory<WriterConfigType extends AbstractWriterConfig<WriterConfigType>,AppenderStatsType extends AbstractWriterStatistics> writerFactory
protected InternalLogger internalLogger
protected AppenderStatsType extends AbstractWriterStatistics appenderStats
protected volatile LogWriter writer
protected ch.qos.logback.core.Layout<LogbackEventType> layout
protected WriterConfigType extends AbstractWriterConfig<WriterConfigType> appenderConfig
public AbstractAppender(WriterConfigType appenderConfig, ThreadFactory threadFactory, WriterFactory<WriterConfigType,AppenderStatsType> writerFactory, AppenderStatsType appenderStats, Class<AppenderStatsMXBeanType> appenderStatsMXBeanClass)
public void setName(String name)
setName in interface ch.qos.logback.core.Appender<LogbackEventType>setName in class ch.qos.logback.core.UnsynchronizedAppenderBase<LogbackEventType>public void setLayout(ch.qos.logback.core.Layout<LogbackEventType> layout)
Encoder; it is a knob that doesn't need to be turned.public void setSynchronous(boolean value)
synchronous configuration property. This can only
be done at the time of configuration, not once the appender is operating.public boolean getSynchronous()
synchronous configuration property.public void setBatchDelay(long value)
batchDelay configuration property.public long getBatchDelay()
batchDelay configuration property.public void setTruncateOversizeMessages(boolean value)
truncateOversizeMessages configuration property.public boolean getTruncateOversizeMessages()
truncateOversizeMessages configuration property.public void setDiscardThreshold(int value)
discardThreshold configuration property.public int getDiscardThreshold()
discardThreshold configuration property.public void setDiscardAction(String value)
discardAction configuration property.public String getDiscardAction()
discardAction configuration property.public void setAssumedRole(String value)
assumedRole configuration property.
Calling this method after the writer has been initialized will have no effect until the next log rotation.
public String getAssumedRole()
assumedRole configuration property.public void setClientFactory(String value)
discardAction configuration property.
Calling this method after the writer has been initialized will have no effect until the next log rotation.
public String getClientFactory()
clientFactory configuration property.public void setClientRegion(String value)
clientRegion configuration property.public String getClientRegion()
clientRegion configuration property.public void setClientEndpoint(String value)
clientEndpoint configuration property.public String getClientEndpoint()
clientEndpoint configuration property.public void setUseShutdownHook(boolean value)
useShutdownHook configuration property.public boolean getUseShutdownHook()
useShutdownHook configuration property.public void setInitializationTimeout(long value)
initializationTimeout configuration property.public long getInitializationTimeout()
initializationTimeout configuration property.public void setEnableBatchLogging(boolean value)
enableBatchLogging configuration property.public boolean getEnableBatchLogging()
enableBatchLogging configuration property.public AppenderStatsType getAppenderStatistics()
public void start()
start in interface ch.qos.logback.core.spi.LifeCyclestart in class ch.qos.logback.core.UnsynchronizedAppenderBase<LogbackEventType>public void stop()
stop in interface ch.qos.logback.core.spi.LifeCyclestop in class ch.qos.logback.core.UnsynchronizedAppenderBase<LogbackEventType>protected void append(LogbackEventType event)
append in class ch.qos.logback.core.UnsynchronizedAppenderBase<LogbackEventType>protected abstract WriterConfigType generateWriterConfig()
protected void registerStatisticsBean()
The name for the bean is consistent with the Log4J LayoutDynamicMBean,
so that it will appear in the hierarchy under the appender.
Note: this method is protected so that it can be avoided during unit tests.
protected void unregisterStatisticsBean()
Note: this method is protected so that it can be avoided during unit tests.
Copyright © 2023. All rights reserved.