Amazon Elastic Container Service
Developer Guide (API Version 2014-11-13)

ecs-cli logs

Retrieves container logs from CloudWatch Logs. Only valid for tasks that use the awslogs driver and have a log stream prefix specified.

Important

Some features described may only be available with the latest version of the Amazon ECS CLI. For more information about obtaining the latest version, see Installing the Amazon ECS CLI.

Syntax

ecs-cli logs --task-id task_id [--task-def task_definition] [--follow] [--filter-pattern search_string] [--since n_minutes] [--start-time 2006-01-02T15:04:05+07:00] [--end-time 2006-01-02T15:04:05+07:00] [--timestamps] [--help]

Options

Name Description

--task-id task_id

Prints the logs for this ECS task.

Type: String

Required: Yes

--task-def task_definition

Specifies the name or full Amazon Resource Name (ARN) of the ECS task definition associated with the task ID. This is only needed if the task has been stopped.

Type: String

Required: No

--follow

Specifies if the logs should be streamed.

Required: No

--filter-pattern search_string

Specifies the substring to search for within the logs.

Type: String

Required: No

--since n

Returns logs newer than a relative duration in minutes. Can't be used with --start-time.

Type: Integer

Required: No

--start-time timestamp

Returns logs after a specific date (format: RFC 3339. Example: 2006-01-02T15:04:05+07:00). Cannot be used with --since flag.

Required: No

--end-time timestamp

Returns logs before a specific date (format: RFC 3339. Example: 2006-01-02T15:04:05+07:00). Cannot be used with --follow.

Required: No

--timestamps

Specifies if timestamps are shown on each line in the log output.

Required: No

--help, -h

Shows the help text for the specified command.

Required: No

Examples

Example

This example prints the log for a task.

ecs-cli logs --task-id task_id

The contents of the log is in the output if successful.

On this page: