0

I have a task in ECS that runs tomcat. That tomcat has 2 or 3 apps deployed to it. I know its not an ideal situation but this is what we've got. Log4j is used and logs for apps goto different log files under logs folder of tomcat. Is there a way I can have those different log files from my docker container to CloudWatch under different streams? I know if I write logs to stdout using log4j appender I can have them in cloudwatch easily but then they will not be separate, it'll be log from all apps going in one place.

Many Thanks

user3756522
  • 93
  • 2
  • 5
  • You can install the Cloudwatch agent on your docker images and setup cron jobs for them to periodically log each log file to a different log group. – David Webster Jan 17 '19 at 08:41
  • If you are using log4j for all your webapp for logging, you can consider using log4j cloudwatch appender to push the logs for you to cloudwatch instead. There are quite a few out there. https://dzone.com/articles/announcing-log4j-aws-appenders https://github.com/sensefly-sa/log4j-cloudwatch-appender https://github.com/speedwing/log4j-cloudwatch-appender – Robin Tan May 17 '19 at 02:43

1 Answers1

1

Instead of using log4j and sending logs to STDOUT you may set your log-configuration and docker log driver to aws-logs, which will help you to send logs directly to the cloudwatch using cloudwatch agent.

Reference: https://aws.amazon.com/blogs/devops/send-ecs-container-logs-to-cloudwatch-logs-for-centralized-monitoring/

mohit
  • 2,325
  • 23
  • 48