A frequent issue in AWS ECS Fargate is missing logs in CloudWatch, even when tasks are running fine.
Here’s a quick guide to diagnose and fix it.
🪶 Root Cause
- The logGroup name or region doesn’t match what your task definition expects.
- Fargate tasks sometimes reuse older task revisions without the correct logging config.
🧰 Step-by-Step Fix
-
Check the task definition: ```bash aws ecs describe-task-definition –task-definition my-app:12
-
Confirm the log configuration section:
```bash “logConfiguration”: { “logDriver”: “awslogs”, “options”: { “awslogs-group”: “/ecs/my-app”, “awslogs-region”: “us-east-1”, “awslogs-stream-prefix”: “ecs” } }
-
If logs are missing, redeploy with:
```bash aws ecs update-service –cluster my-cluster –service my-service –force-new-deployment
-
Bonus Tip - Add this to your terraform or CloudFormation to avoid drift:
```bash log_configuration { log_driver = “awslogs” options = { awslogs-group = “/ecs/my-app” awslogs-region = “us-east-1” awslogs-stream-prefix = “ecs” } }
🧩 Consistent log delivery means predictable debugging — one of the quiet strengths of any DevOps pipeline!