aws-cdk-lib.aws_ecs.AwsLogDriverProps

interface AwsLogDriverProps

LanguageType name
.NETAmazon.CDK.AWS.ECS.AwsLogDriverProps
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsecs#AwsLogDriverProps
Javasoftware.amazon.awscdk.services.ecs.AwsLogDriverProps
Pythonaws_cdk.aws_ecs.AwsLogDriverProps
TypeScript (source)aws-cdk-lib » aws_ecs » AwsLogDriverProps

Specifies the awslogs log driver configuration options.

Example

// 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

NameTypeDescription
streamPrefixstringPrefix for the log streams.
datetimeFormat?stringThis option defines a multiline start pattern in Python strftime format.
logGroup?ILogGroupThe log group to log to.
logRetention?RetentionDaysThe number of days log events are kept in CloudWatch Logs when the log group is automatically created by this construct.
mode?AwsLogDriverModeThe delivery mode of log messages from the container to awslogs.
multilinePattern?stringThis option defines a multiline start pattern using a regular expression.

streamPrefix

Type: string

Prefix for the log streams.

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

datetimeFormat?

Type: string (optional, default: No multiline matching.)

This option defines a multiline start pattern in Python strftime format.

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.


logGroup?

Type: ILogGroup (optional, default: A log group is automatically created.)

The log group to log to.


logRetention?

Type: RetentionDays (optional, default: Logs never expire.)

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


mode?

Type: AwsLogDriverMode (optional, default: AwsLogDriverMode.BLOCKING)

The delivery mode of log messages from the container to awslogs.


multilinePattern?

Type: string (optional, default: No multiline matching.)

This option defines a multiline start pattern using a regular expression.

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.