# AwsLogDriverMode

awslogs provides two modes for delivering messages from the container to the log driver.

- Source: [`aws-ecs/lib/log-drivers/aws-log-driver.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-ecs/lib/log-drivers/aws-log-driver.ts#L16)

## Example

```ts
declare const cluster: ecs.Cluster;
// Create a Task Definition for the container to start
const taskDefinition = new ecs.Ec2TaskDefinition(this, 'TaskDef');
taskDefinition.addContainer('TheContainer', {
  image: ecs.ContainerImage.fromAsset(path.resolve(__dirname, '..', 'eventhandler-image')),
  memoryLimitMiB: 256,
  logging: new ecs.AwsLogDriver({ streamPrefix: 'EventDemo', mode: ecs.AwsLogDriverMode.NON_BLOCKING }),
});

// An Rule that describes the event trigger (in this case a scheduled run)
const rule = new events.Rule(this, 'Rule', {
  schedule: events.Schedule.expression('rate(1 minute)'),
});

// Pass an environment variable to the container 'TheContainer' in the task
rule.addTarget(new targets.EcsTask({
  cluster,
  taskDefinition,
  taskCount: 1,
  containerOverrides: [{
    containerName: 'TheContainer',
    environment: [{
      name: 'I_WAS_TRIGGERED',
      value: 'From CloudWatch Events'
    }],
  }],
}));
```

## Members

| Member | Description |
| --- | --- |
| `BLOCKING` | (default) direct, blocking delivery from container to driver. |
| `NON_BLOCKING` | The non-blocking message delivery mode prevents applications from blocking due to logging back pressure. |

## Referenced by

- [`AwsLogDriverProps`](/v2/docs/aws-cdk-lib.aws_ecs.AwsLogDriverProps).mode
