Skip to content
v2.276.0

AwsLogDriverProps Struct ​

Specifies the awslogs log driver configuration options.

Example ​

ts
// Create a Task Definition for the Windows container to start
const taskDefinition = new ecs.FargateTaskDefinition(this, 'TaskDef', {
  runtimePlatform: {
    operatingSystemFamily: ecs.OperatingSystemFamily.WINDOWS_SERVER_2019_CORE,
    cpuArchitecture: ecs.CpuArchitecture.X86_64,
  },
  cpu: 1024,
  memoryLimitMiB: 2048,
});

taskDefinition.addContainer('windowsservercore', {
  logging: ecs.LogDriver.awsLogs({ streamPrefix: 'win-iis-on-fargate' }),
  portMappings: [{ containerPort: 80 }],
  image: ecs.ContainerImage.fromRegistry('mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019'),
});

Properties ​

datetimeFormatoptionalstringdatetime_formatoptionalstrdatetimeFormatoptionalStringDatetimeFormatoptionalstringDatetimeFormatoptional*string#
This option defines a multiline start pattern in Python strftime format.

Default: No multiline matching.

A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. Thus the matched line is the delimiter between log messages.

logGroupoptionalILogGroupReflog_groupoptionalILogGroupReflogGroupoptionalILogGroupRefLogGroupoptionalILogGroupRefLogGroupoptionalILogGroupRef#
The log group to log to.

Default: A log group is automatically created.

logRetentionoptionalRetentionDayslog_retentionoptionalRetentionDayslogRetentionoptionalRetentionDaysLogRetentionoptionalRetentionDaysLogRetentionoptionalRetentionDays#
The number of days log events are kept in CloudWatch Logs when the log group is automatically created by this construct.

Default: Logs never expire.

maxBufferSizeoptionalSizemax_buffer_sizeoptionalSizemaxBufferSizeoptionalSizeMaxBufferSizeoptionalSizeMaxBufferSizeoptionalSize#
When AwsLogDriverMode.NON_BLOCKING is configured, this parameter controls the size of the non-blocking buffer used to temporarily store messages. This parameter is not valid with AwsLogDriverMode.BLOCKING.

Default: 1 megabyte if driver mode is non-blocking, otherwise this property is not set

modeoptionalAwsLogDriverModemodeoptionalAwsLogDriverModemodeoptionalAwsLogDriverModeModeoptionalAwsLogDriverModeModeoptionalAwsLogDriverMode= AwsLogDriverMode.BLOCKING#
The delivery mode of log messages from the container to awslogs.
multilinePatternoptionalstringmultiline_patternoptionalstrmultilinePatternoptionalStringMultilinePatternoptionalstringMultilinePatternoptional*string#
This option defines a multiline start pattern using a regular expression.

Default: No multiline matching.

A log message consists of a line that matches the pattern and any following lines that don’t match the pattern. Thus the matched line is the delimiter between log messages.

This option is ignored if datetimeFormat is also configured.

streamPrefixstringstream_prefixstrstreamPrefixStringStreamPrefixstringStreamPrefix*stringrequired#
Prefix for the log streams.
notes

The awslogs-stream-prefix option allows you to associate a log stream with the specified prefix, the container name, and the ID of the Amazon ECS task to which the container belongs. If you specify a prefix with this option, then the log stream takes the following format:

prefix-name/container-name/ecs-task-id