我在AWS Elastic Beanstalk中部署了一个PHP Laravel Worker&想要将/var/app/current/storage/logs/*.log
流式传输到 CloudWatch 。但是,我遇到的解决方案是 Forge 部署或vanilla EC2 实例。
对此事的任何帮助表示感谢。
答案 0 :(得分:7)
您需要按照here所述配置CloudWatch代理:
我认为 logs.config 应该如下所示
option_settings:
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: StreamLogs
value: true
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: DeleteOnTerminate
value: false
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: RetentionInDays
value: 7
packages:
yum:
awslogs: []
files:
"/etc/awslogs/awscli.conf" :
mode: "000600"
owner: root
group: root
content: |
[plugins]
cwlogs = cwlogs
[default]
region = `{"Ref":"AWS::Region"}`
"/etc/awslogs/awslogs.conf" :
mode: "000600"
owner: root
group: root
content: |
[general]
state_file = /var/lib/awslogs/agent-state
"/etc/awslogs/config/logs.conf" :
mode: "000600"
owner: root
group: root
content: |
[/var/app/current/storage/logs]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/app/current/storage/logs"]]}`
log_stream_name = {instance_id}
file = /var/app/current/storage/logs/*.log
commands:
"01":
command: chkconfig awslogs on
"02":
command: service awslogs restart
请参阅ec2实例的 /var/log/awslogs.log 进行故障排除。