AwsLogDriverProps

class aws_cdk.aws_ecs.AwsLogDriverProps(*, stream_prefix, datetime_format=None, log_group=None, log_retention=None, max_buffer_size=None, mode=None, multiline_pattern=None)

Bases: object

Specifies the awslogs log driver configuration options.

Parameters:
  • stream_prefix (str) – 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

  • datetime_format (Optional[str]) – 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. Default: - No multiline matching.

  • log_group (Optional[ILogGroup]) – The log group to log to. Default: - A log group is automatically created.

  • log_retention (Optional[RetentionDays]) – 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.

  • max_buffer_size (Optional[Size]) – 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

  • mode (Optional[AwsLogDriverMode]) – The delivery mode of log messages from the container to awslogs. Default: - AwsLogDriverMode.BLOCKING

  • multiline_pattern (Optional[str]) – 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. Default: - No multiline matching.

ExampleMetadata:

infused

Example:

# Create a Task Definition for the Windows container to start
task_definition = ecs.FargateTaskDefinition(self, "TaskDef",
    runtime_platform=ecs.RuntimePlatform(
        operating_system_family=ecs.OperatingSystemFamily.WINDOWS_SERVER_2019_CORE,
        cpu_architecture=ecs.CpuArchitecture.X86_64
    ),
    cpu=1024,
    memory_limit_mi_b=2048
)

task_definition.add_container("windowsservercore",
    logging=ecs.LogDriver.aws_logs(stream_prefix="win-iis-on-fargate"),
    port_mappings=[ecs.PortMapping(container_port=80)],
    image=ecs.ContainerImage.from_registry("mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019")
)

Attributes

datetime_format

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.

Default:
  • No multiline matching.

log_group

The log group to log to.

Default:
  • A log group is automatically created.

log_retention

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.

max_buffer_size

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

mode

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

Default:
  • AwsLogDriverMode.BLOCKING

multiline_pattern

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.

Default:
  • No multiline matching.

stream_prefix

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