# GenericLogDriver

A log driver that sends logs to the specified driver.

Extends: [LogDriver](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.LogDriver.html) › GenericLogDriver

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

## Example

TypeScript:

```ts
// Create a Task Definition for the container to start
const taskDefinition = new ecs.Ec2TaskDefinition(this, 'TaskDef');
taskDefinition.addContainer('TheContainer', {
  image: ecs.ContainerImage.fromRegistry('example-image'),
  memoryLimitMiB: 256,
  logging: new ecs.GenericLogDriver({
    logDriver: 'fluentd',
    options: {
      tag: 'example-tag',
    },
  }),
});
```

Python:

```python
# Create a Task Definition for the container to start
task_definition = ecs.Ec2TaskDefinition(self, "TaskDef")
task_definition.add_container("TheContainer",
    image=ecs.ContainerImage.from_registry("example-image"),
    memory_limit_mi_b=256,
    logging=ecs.GenericLogDriver(
        log_driver="fluentd",
        options={
            "tag": "example-tag"
        }
    )
)
```

Java:

```java
// Create a Task Definition for the container to start
Ec2TaskDefinition taskDefinition = new Ec2TaskDefinition(this, "TaskDef");
taskDefinition.addContainer("TheContainer", ContainerDefinitionOptions.builder()
        .image(ContainerImage.fromRegistry("example-image"))
        .memoryLimitMiB(256)
        .logging(GenericLogDriver.Builder.create()
                .logDriver("fluentd")
                .options(Map.of(
                        "tag", "example-tag"))
                .build())
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Create a Task Definition for the container to start
var taskDefinition = new Ec2TaskDefinition(this, "TaskDef");
taskDefinition.AddContainer("TheContainer", new ContainerDefinitionOptions {
    Image = ContainerImage.FromRegistry("example-image"),
    MemoryLimitMiB = 256,
    Logging = new GenericLogDriver(new GenericLogDriverProps {
        LogDriver = "fluentd",
        Options = new Dictionary<string, string> {
            { "tag", "example-tag" }
        }
    })
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Create a Task Definition for the container to start
taskDefinition := ecs.NewEc2TaskDefinition(this, jsii.String("TaskDef"))
taskDefinition.AddContainer(jsii.String("TheContainer"), &ContainerDefinitionOptions{
	Image: ecs.ContainerImage_FromRegistry(jsii.String("example-image")),
	MemoryLimitMiB: jsii.Number(256),
	Logging: ecs.NewGenericLogDriver(&GenericLogDriverProps{
		LogDriver: jsii.String("fluentd"),
		Options: map[string]*string{
			"tag": jsii.String("example-tag"),
		},
	}),
})
```

## Initializer

TypeScript:

```ts
new GenericLogDriver(props: GenericLogDriverProps)
```

Python:

```python
GenericLogDriver(props: GenericLogDriverProps)
```

Java:

```java
new GenericLogDriver(GenericLogDriverProps props)
```

C# / .NET:

```csharp
new GenericLogDriver(GenericLogDriverProps props)
```

Golang:

```go
NewGenericLogDriver(Props GenericLogDriverProps)
```

## Methods

- `awsLogs(props: AwsLogDriverProps): LogDriver` (static) — Creates a log driver configuration that sends log information to CloudWatch Logs.

- `bind(_scope: Construct, _containerDefinition: ContainerDefinition): LogDriverConfig` — Called when the log driver is configured on a container.
