Skip to content
v2.275.0

GenericLogDriver Class ​

A log driver that sends logs to the specified driver.

Example ​

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
# 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
// 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());
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" }
        }
    })
});
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 ​

ts
new GenericLogDriver(props: GenericLogDriverProps)
python
GenericLogDriver(props: GenericLogDriverProps)
java
new GenericLogDriver(GenericLogDriverProps props)
csharp
new GenericLogDriver(GenericLogDriverProps props)
go
NewGenericLogDriver(Props GenericLogDriverProps)

Methods ​

awsLogs(props: AwsLogDriverProps): LogDriver@staticmethod def aws_logs(props: AwsLogDriverProps) -> LogDriverpublic static LogDriver awsLogs(AwsLogDriverProps props)public static LogDriver AwsLogs(AwsLogDriverProps props)func AwsLogs(Props AwsLogDriverProps) LogDriverstatic#
Creates a log driver configuration that sends log information to CloudWatch Logs.
bind(_scope: Construct, _containerDefinition: ContainerDefinition): LogDriverConfigdef bind(self, _scope: Construct, _container_definition: ContainerDefinition) -> LogDriverConfigpublic LogDriverConfig bind(Construct _scope, ContainerDefinition _containerDefinition)public LogDriverConfig Bind(Construct _scope, ContainerDefinition _containerDefinition)func Bind(_scope Construct, _containerDefinition ContainerDefinition) LogDriverConfig#
Called when the log driver is configured on a container.