# How to check ECS task logs

How-to guides · Updated 17 November 2026

**Short answer:** With the awslogs log driver, each container writes to the CloudWatch Logs group set in the task definition, in a stream named PREFIX/CONTAINER/TASK_ID. In the console, open the task and choose the Logs tab. From the CLI, run aws logs tail LOG_GROUP --log-stream-name-prefix PREFIX/CONTAINER/TASK_ID --since 1h. If there are no logs, check the task definition's logConfiguration and the task execution role's CloudWatch Logs permissions.

## Find the log group and stream

```
aws ecs describe-task-definition --task-definition web \
  --query 'taskDefinition.containerDefinitions[].{name:name,driver:logConfiguration.logDriver,opts:logConfiguration.options}'
```

Typical options: `awslogs-group` = `/ecs/web`, `awslogs-region` = `eu-west-2`, `awslogs-stream-prefix` = `ecs`. The stream for container `app` in task `0f9e1b2c3d4e5f6a7b8c9d0e1f2a3b4c` is then `ecs/app/0f9e1b2c3d4e5f6a7b8c9d0e1f2a3b4c`.

## Console steps

1. Open **ECS > Clusters > cluster > Services > service > Tasks** (set the filter to *Stopped* for tasks that already exited).
2. Choose the task, then the **Logs** tab, which shows recent lines per container.
3. Choose **View in CloudWatch** for the full stream, or open the service's **Logs** tab to see all its tasks together.

## CLI steps

```
# All tasks of the service, live
aws logs tail /ecs/web --follow --since 15m --format short

# One task (take the ID from the task ARN)
aws logs tail /ecs/web --since 2h \
  --log-stream-name-prefix ecs/app/0f9e1b2c3d4e5f6a7b8c9d0e1f2a3b4c

# Last lines of the most recently stopped task
TASK=$(aws ecs list-tasks --cluster prod --service-name web --desired-status STOPPED \
  --query 'taskArns[0]' --output text | awk -F/ '{print $NF}')
aws logs tail /ecs/web --since 6h --log-stream-name-prefix ecs/app/$TASK | tail -50
```

Crash output just before exit is usually the most useful part. Pair it with the stopped reason from [service events](https://cloudconsole.dev/how-to/check-ecs-service-events) and `describe-tasks`.

## No logs? Check these

| Symptom | Cause and fix |
|---|---|
| No stream at all, task stopped with `ResourceInitializationError` | Execution role lacks `logs:CreateLogStream`/`logs:PutLogEvents`, or the log group doesn't exist; add `awslogs-create-group` = `true` plus `logs:CreateLogGroup`, or create the group. See [ResourceInitializationError](https://cloudconsole.dev/errors/ecs-resourceinitializationerror) |
| Stream exists but is empty | The app logs to a file instead of stdout/stderr, or buffers output (Python without `-u` / `PYTHONUNBUFFERED=1`) |
| Task never started | Image pull or placement failed before the container ran; nothing to log. Check stopped reason |
| Private subnet, no logs | No route to CloudWatch Logs: add a NAT gateway or a `logs` interface endpoint |
| FireLens / other drivers | Logs go wherever Fluent Bit routes them, not to `/ecs/...` |

## Common mistakes

- **Waiting too long** to look at a stopped task: the task disappears from the console after a while, but its log stream remains, so search the log group by task ID.
- **No retention**: set a retention period on `/ecs/...` groups; see [log retention](https://cloudconsole.dev/how-to/set-cloudwatch-log-retention).
- **Blocking mode**: the awslogs driver's default blocking mode can stall the app if CloudWatch Logs is unreachable; non-blocking mode trades that for possible log loss.

## Questions

### Where are ECS container logs?

With the awslogs driver, in the CloudWatch Logs group named in the task definition, in a stream named prefix/container-name/task-id.

### Why does my ECS task have no logs?

Usually the execution role can't write to CloudWatch Logs, the log group doesn't exist, the task has no network path to CloudWatch Logs, or the app writes to a file rather than stdout.

### How do I see logs for a stopped ECS task?

Its log stream stays in CloudWatch Logs. Search the log group for a stream with the task ID, for example with aws logs tail --log-stream-name-prefix.

## When this happens away from your desk

Container logs are where most ECS incidents are actually explained. CloudConsole, a phone app for AWS, is being built to show logs, service events and alarms on your phone, so you can read the crash output without opening a laptop.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Send Amazon ECS logs to CloudWatch](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_awslogs.html)
- [Amazon ECS task execution IAM role](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_execution_IAM_role.html)

## Related

- [How to check ECS service events](https://cloudconsole.dev/how-to/check-ecs-service-events)
- [How to tail CloudWatch logs](https://cloudconsole.dev/how-to/tail-cloudwatch-logs)
- [ResourceInitializationError: unable to pull secrets or registry auth](https://cloudconsole.dev/errors/ecs-resourceinitializationerror)
- [Essential container in task exited](https://cloudconsole.dev/errors/ecs-essential-container-exited)
- [How to exec into an ECS container](https://cloudconsole.dev/how-to/ecs-exec-into-container)
- [How to add my IP to an AWS security group](https://cloudconsole.dev/how-to/add-my-ip-to-security-group)

---

Source: https://cloudconsole.dev/how-to/view-ecs-task-logs

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
