GenericLogDriverProps Struct
The configuration to use when creating a log driver.
| Source | aws-ecs/lib/log-drivers/generic-log-driver.ts |
|---|
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"),
},
}),
})
Properties
The log driver to use for the container.
notes
The valid values listed for this parameter are log drivers that the Amazon ECS container agent can communicate with by default.
For tasks using the Fargate launch type, the supported log drivers are awslogs and splunk. For tasks using the EC2 launch type, the supported log drivers are awslogs, syslog, gelf, fluentd, splunk, journald, and json-file.
For more information about using the awslogs log driver, see Using the awslogs Log Driver in the Amazon Elastic Container Service Developer Guide.
optionsoptional{ [key: string]: string }optionsoptionaltyping.Mapping[str, str]optionsoptionalMap<String, String>OptionsoptionalIDictionary<string, string>Optionsoptional*map[string]*string #The configuration options to send to the log driver.
Default: the log driver options.
secretOptionsoptional{ [key: string]: Secret }secret_optionsoptionaltyping.Mapping[str, Secret]secretOptionsoptionalMap<String, Secret>SecretOptionsoptionalIDictionary<string, Secret>SecretOptionsoptional*map[string]Secret #The secrets to pass to the log configuration.
Default: no secret options provided.