LogDrivers Class
The base class for log drivers.
Example
ts
declare const secret: ecs.Secret;
// 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: ecs.LogDrivers.splunk({
secretToken: secret,
url: 'my-splunk-url',
}),
});
python
# secret: ecs.Secret
# 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.LogDrivers.splunk(
secret_token=secret,
url="my-splunk-url"
)
)
java
Secret secret;
// 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(LogDrivers.splunk(SplunkLogDriverProps.builder()
.secretToken(secret)
.url("my-splunk-url")
.build()))
.build());
csharp
// Install: dotnet add package Amazon.CDK.Lib
Secret secret;
// 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 = LogDrivers.Splunk(new SplunkLogDriverProps {
SecretToken = secret,
Url = "my-splunk-url"
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var secret Secret
// 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.LogDrivers_Splunk(&SplunkLogDriverProps{
SecretToken: secret,
Url: jsii.String("my-splunk-url"),
}),
})
Initializer
ts
new LogDrivers()
python
LogDrivers()
java
new LogDrivers()
csharp
new LogDrivers()
go
NewLogDrivers()
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.
firelens(props: FireLensLogDriverProps): LogDriver@staticmethod def firelens(props: FireLensLogDriverProps) -> LogDriverpublic static LogDriver firelens(FireLensLogDriverProps props)public static LogDriver Firelens(FireLensLogDriverProps props)func Firelens(Props FireLensLogDriverProps) LogDriverstatic#Creates a log driver configuration that sends log information to firelens log router.
For detail configurations, please refer to Amazon ECS FireLens Examples: https://github.com/aws-samples/amazon-ecs-firelens-examples
fluentd(props?: FluentdLogDriverProps): LogDriver@staticmethod def fluentd(props: typing.Optional[FluentdLogDriverProps] = None) -> LogDriverpublic static LogDriver fluentd(FluentdLogDriverProps props)public static LogDriver Fluentd(FluentdLogDriverProps? props = null)func Fluentd(Props FluentdLogDriverProps) LogDriverstatic#Creates a log driver configuration that sends log information to fluentd Logs.
gelf(props: GelfLogDriverProps): LogDriver@staticmethod def gelf(props: GelfLogDriverProps) -> LogDriverpublic static LogDriver gelf(GelfLogDriverProps props)public static LogDriver Gelf(GelfLogDriverProps props)func Gelf(Props GelfLogDriverProps) LogDriverstatic#Creates a log driver configuration that sends log information to gelf Logs.
journald(props?: JournaldLogDriverProps): LogDriver@staticmethod def journald(props: typing.Optional[JournaldLogDriverProps] = None) -> LogDriverpublic static LogDriver journald(JournaldLogDriverProps props)public static LogDriver Journald(JournaldLogDriverProps? props = null)func Journald(Props JournaldLogDriverProps) LogDriverstatic#Creates a log driver configuration that sends log information to journald Logs.
jsonFile(props?: JsonFileLogDriverProps): LogDriver@staticmethod def json_file(props: typing.Optional[JsonFileLogDriverProps] = None) -> LogDriverpublic static LogDriver jsonFile(JsonFileLogDriverProps props)public static LogDriver JsonFile(JsonFileLogDriverProps? props = null)func JsonFile(Props JsonFileLogDriverProps) LogDriverstatic#Creates a log driver configuration that sends log information to json-file Logs.
none(): LogDriver@staticmethod def none() -> LogDriverpublic static LogDriver none()public static LogDriver None()func None() LogDriverstatic#Creates a log driver configuration that disables logging (Docker `none` driver).
splunk(props: SplunkLogDriverProps): LogDriver@staticmethod def splunk(props: SplunkLogDriverProps) -> LogDriverpublic static LogDriver splunk(SplunkLogDriverProps props)public static LogDriver Splunk(SplunkLogDriverProps props)func Splunk(Props SplunkLogDriverProps) LogDriverstatic#Creates a log driver configuration that sends log information to splunk Logs.
syslog(props?: SyslogLogDriverProps): LogDriver@staticmethod def syslog(props: typing.Optional[SyslogLogDriverProps] = None) -> LogDriverpublic static LogDriver syslog(SyslogLogDriverProps props)public static LogDriver Syslog(SyslogLogDriverProps? props = null)func Syslog(Props SyslogLogDriverProps) LogDriverstatic#Creates a log driver configuration that sends log information to syslog Logs.