7

How can I configure ECS Fargate + Cloudwatch to include specific file location.

I have app-access.log where my framework puts all of my access logs. Cloudwatch currently consumes logs from my server command IO only. How can I tell ECS Fargate to use app-access.log also.

PS. I am using Cloudformation.

roxxypoxxy
  • 2,973
  • 1
  • 21
  • 28

1 Answers1

9

ECS or Cloudwatch don't watch files in the container. ECS has integration with the docker logs, if the docker container emits logs from the access.log then these will be available for Cloudwatch. That's why you're only seeing the IO commands.

So it's not about ECS but rather about how docker logging works. See here for more details on docker logging.

You have to make sure any logline is written to STDOUT or STDERR. One method is to symlink /path/to/app-access.log -> /dev/stdout. But usually, it's easier to make sure there's a console appender for your service.

LiorH
  • 18,524
  • 17
  • 70
  • 98
  • 4
    Thank you. `RUN ln -s /dev/stdout ./app-access.log` in Dockerfile worked for me. – roxxypoxxy Nov 08 '18 at 15:07
  • hi @roxxypoxxy, I tried added that line in Dockerfile and it successfully running in ecs fargate tasks, but can you tell me how can I check that file? – Swe Zin Phyoe Sep 23 '20 at 10:11