public class CloudWatchAppender<LogbackEventType> extends AbstractAppender<CloudWatchWriterConfig,CloudWatchWriterStatistics,CloudWatchWriterStatisticsMXBean,LogbackEventType>
This appender supports the following configuration parameters:
| logGroup | Name of the CloudWatch log group where messages are sent; may use
substitutions. If this group doesn't exist it will be created.
You typically assign a single log group to an application, and then use multiple log streams for instances of that application. There is no default value. If you do not configure the log group, the appender will be disabled and will report its misconfiguration. |
|---|---|
| logStream | Name of the CloudWatch log stream where messages are sent; may use
substitutions. If this stream doesn't exist it will be created.
You typically create a separate log stream for each instance of the application.
Default value is |
| retentionPeriod | (optional) Specifies a retention period for created CloudWatch log groups. If omitted, messages are retained forever. Note that values are restricted; see AWS API doc. |
| dedicatedWriter | If true, the appender assumes that it will be the only writer to the log stream, and will not retrieve a sequence token before each write. Defaults to false for legacy behavior. |
| rotationMode | Controls whether auto-rotation is enabled. Values are none, count, interval, hourly, and daily; default is none. |
| rotationInterval | Sets the rotation interval, for those appenders that support rotation.
This parameter is valid only when the rotationMode parameter
is "interval" or "count": for the former, it's the number of milliseconds
between rotations, for the latter the number of messages.
If using interval rotation, you should include |
| sequence | A value that is incremented each time the stream is rotated. May be
accessed as the {sequence} substitution. Defaults to 0.
|
| synchronous | If true, the appender will operate in synchronous mode: calls to
append() execute on the caller's thread, and will not return until
writer has attempted to send a batch (errors may still result in
messages being requeued for the next batch). This negates the benefits
of message batching, and should only be used in cases (like AWS Lambda)
where background thread processing is not guaranteed.
Note: setting |
| batchDelay | The time, in milliseconds, that the writer will wait to accumulate
messages for a batch.
The writer attempts to gather multiple logging messages into a batch, to reduce communication with the service. The batch delay controls the time that a message will remain in-memory while the writer builds this batch. In a low-volume environment it will be the main determinant of when the batch is sent; in a high volume environment it's likely that the maximum request size will be reached before the delay elapses. The default value is 2000, which is rather arbitrarily chosen. If the appender is in synchronous mode, this setting is ignored. |
| truncateOversizeMessages | If true (the default), oversize messages are truncated to
the maximum length permitted by CloudWatch Logs. If false
they are discarded. In either case, the oversized message is reported
to the Logback debug log.
|
| discardThreshold | The number of unsent messages that will trigger message discard. A
high value is useful when network connectivity is intermittent and/or
overall AWS communication is causing throttling. However, a value that
is too high may cause out-of-memory errors.
The default, 10,000, is based on the assumptions that (1) each message will be 1k or less, and (2) any app that uses remote logging can afford 10MB.
|
| discardAction | The action to take when the number of unsent messages exceeds the
discard threshold. Values are "none" (retain all messages), "oldest"
(discard oldest messages), and "newest" (discard most recent messages).
The default is "oldest". Attempting to set an incorrect value will throw a configuration error. |
| assumedRole | Specifies role name or ARN that will be assumed by this appender. Useful for cross-account logging. If the appender does not have permission to assume this role, initialization will fail. |
| clientFactory | The fully-qualified name of a static method to create the correct AWS
client, which will be called instead of the writer's internal client
factory. This is useful if you need non-default configuration, such as
using a proxy server.
The passed string is of the form |
| clientRegion | Specifies a non-default service region. This setting is ignored if you
use a client factory.
Note that the region must be supported by the current SDK version. |
| clientEndpoint | Specifies a non-default service endpoint. This is intended for use with older AWS SDK versions that do not provide client factories and default to us-east-1 for constructed clients, although it can be used for newer releases when you want to override the default region provider. This setting is ignored if you use a client factory. |
| useShutdownHook | Controls whether the appender uses a shutdown hook to attempt to process outstanding messages when the JVM exits. This is true by default; set to false to disable. |
appenderStats, assumedRole, batchDelay, clientEndpoint, clientFactory, clientRegion, discardAction, discardThreshold, internalLogger, lastRotationTimestamp, layout, messagesSinceLastRotation, rotationInterval, rotationMode, sequence, synchronous, threadFactory, truncateOversizeMessages, useShutdownHook, writer, writerFactory| Constructor and Description |
|---|
CloudWatchAppender() |
| Modifier and Type | Method and Description |
|---|---|
protected CloudWatchWriterConfig |
generateWriterConfig()
Called just before a writer is created, so that the subclass can
perform substitutions on the configuration.
|
boolean |
getDedicatedWriter()
Returns the
dedicatedWriter configuration property. |
String |
getLogGroup()
Returns the
logGroup configuration property. |
String |
getLogStream()
Returns the
logStream configuration property. |
Integer |
getRetentionPeriod()
Returns the
retentionPeriod configuration property,
null to indicate unlimited retention. |
void |
rotate()
Rotates the log writer.
|
void |
setDedicatedWriter(boolean value)
Sets the
dedicatedWriter configuration property. |
void |
setLogGroup(String value)
Sets the
logGroup configuration property. |
void |
setLogStream(String value)
Sets the
logStream configuration property. |
void |
setRetentionPeriod(int value)
Sets the
retentionPeriod configuration property. |
void |
setRotationMode(String value)
Sets the
rotationMode configuration property. |
append, getAppenderStatistics, getAssumedRole, getBatchDelay, getClientEndpoint, getClientFactory, getClientRegion, getDiscardAction, getDiscardThreshold, getRotationInterval, getRotationMode, getSequence, getSynchronous, getTruncateOversizeMessages, getUseShutdownHook, registerStatisticsBean, setAssumedRole, setBatchDelay, setClientEndpoint, setClientFactory, setClientRegion, setDiscardAction, setDiscardThreshold, setLayout, setName, setRotationInterval, setSequence, setSynchronous, setTruncateOversizeMessages, setUseShutdownHook, shouldRotate, start, stop, unregisterStatisticsBeanaddFilter, clearAllFilters, doAppend, getCopyOfAttachedFiltersList, getFilterChainDecision, getName, isStarted, toStringaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextpublic void setLogGroup(String value)
logGroup configuration property.public String getLogGroup()
logGroup configuration property.public void setLogStream(String value)
logStream configuration property.public String getLogStream()
logStream configuration property.public void setRetentionPeriod(int value)
retentionPeriod configuration property.public Integer getRetentionPeriod()
retentionPeriod configuration property,
null to indicate unlimited retention.public void setDedicatedWriter(boolean value)
dedicatedWriter configuration property.public boolean getDedicatedWriter()
dedicatedWriter configuration property.public void setRotationMode(String value)
rotationMode configuration property.
This method must be explicitly overridden and made public by appenders that support rotation.
public void rotate()
protected CloudWatchWriterConfig generateWriterConfig()
AbstractAppenderCopyright © 2020. All rights reserved.