0
votes

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

1
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
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. dzone.com/articles/announcing-log4j-aws-appenders github.com/sensefly-sa/log4j-cloudwatch-appender github.com/speedwing/log4j-cloudwatch-appender - Robin Tan

1 Answers

1
votes

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/