By using AWS re:Post, you agree to the Terms of Use

Where are ECS Task logs being stored and for how long?

0

I am running an ECS cluster service powered by EC2. When I log onto the server, which was created with the ECS optimised AMI (AMI ID: ami-040d909ea4e56f8f3) - I can look into the docker logs for the Tasks I have running.

My log options in my Task Definition are:

 "logConfiguration": {
    "logDriver": "awslogs",
    "secretOptions": null,
    "options": {
      "awslogs-group": "logGroupName",
      "awslogs-region": "us-east-1",
      "awslogs-stream-prefix": "PrefixName"
    }
  }

As the logs are being forwarded to CloudWatch, they should be deleted from the instance - am I right? It doesn't make sense that an ECS optimised instance was created without this in mind.

My question simply is - where are these logs stored. Not the agent logs, as I can find the documentation for it, but the actual container logs. And when are they removed from the EC2 instance?

1 Answer
0
Accepted Answer

The awslogs driver simply forwards your container STDOUT and STDERR log streams to CloudWatch Logs. It does not read from a specific location in your filesystem. Therefore, your application will need to be configured in such a way that the logs are emitted via the STDOUT and STDERR log streams.

If your application is also writing the logs to a custom location, you will have to perform log rotation to clean up these logs to avoid file system exhaustion.

profile picture
SUPPORT ENGINEER
answered 24 days ago
  • Thanks for getting back to me. Highly appreciated.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions