I have a Tomcat app on Elastic Beanstalk, and I want to send logs to Cloudwatch Logs. To that end, I set up log4j to write to file, and in .ebextension
, amazon-cloudwatch-agent
is installed and run.
commands:
# 00_download_and_install:
# command: rpm --upgrade --force https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
01_start:
command: /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -c file:/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json -s
packages:
yum:
amazon-cloudwatch-agent: []
files:
"/opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json":
content: |
{...
}
Unfortunately, every time I deploy the app to Elastic Beanstalk, the agent shuts down, and I have to restart it manually via ssh.