````
#It looks like you're trying to use AWS Elastic Beanstalk to create a custom CloudWatch log group. To do this, you'll need to use an Elastic Beanstalk configuration file called logs.config to specify the settings for your log group.
#Here is an example logs.config file that you can use as a starting point:
files:
"/etc/awslogs/awscli.conf":
mode: "000600"
owner: root
group: root
content: |
[plugins]
cwlogs = cwlogs
[default]
region = `{"Ref":"AWS::Region"}`
"/etc/awslogs/config/logs.conf":
mode: "000600"
owner: root
group: root
content: |
[/var/log/celery_beat.stdout.log]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "/var/log/celery_beat.stdout.log"]]}`
log_stream_name = {instance_id}
file = /var/log/celery_beat.stdout.log
[/var/log/celery_flower.stdout.log]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "/var/log/celery_flower.stdout.log"]]}`
log_stream_name = {instance_id}
file = /var/log/celery_flower.stdout.log
[/var/log/celery_worker.stdout.log]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "/var/log/celery_worker.stdout.log"]]}`
log_stream_name = {instance_id}
file = /var/log/celery_worker.stdout.log
commands:
"01":
command: systemctl enable awslogsd.service
"02":
command: systemctl restart awslogsd
#This configuration file will create a CloudWatch log group for each of the log files you specified (/var/log/celery_beat.stdout.log, /var/log/celery_flower.stdout.log, and /var/log/celery_worker.stdout.log). The log group will be named using the environment name of your Elastic Beanstalk environment.
#To use this configuration file, you'll need to save it as .ebextensions/logs.config in the root of your Elastic Beanstalk application source code. Then, when you deploy your application to Elastic Beanstalk, the log group will be created automatically.
#I hope this helps! Let me know if you have any other questions.
I've detailed in a new [Medium blog][1] how this all works and an example .ebextensions file and **where** to put it.
[![location in Java Web application][2]][2]
Below is an excerpt that you might be able to use, though the article explains how to determine the right folder/file(s) to stream.
```
packages:
yum:
awslogs: []
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: 90
files:
"/etc/awslogs/awscli.conf" :
mode: "000600"
owner: root
group: root
content: |
[plugins]
cwlogs = cwlogs
[default]
region = `{"Ref":"AWS::Region"}`
"/etc/awslogs/config/logs.conf" :
mode: "000600"
owner: root
group: root
content: |
[/var/log/tomcat/localhost.log]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/tomcat/localhost.log"]]}`
log_stream_name = {instance_id}
file = /var/log/tomcat/localhost.*
[/var/log/tomcat/catalina.log]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/tomcat/catalina.log"]]}`
log_stream_name = {instance_id}
file = /var/log/tomcat/catalina.*
[/var/log/tomcat/localhost_access_log.txt]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/tomcat/access_log"]]}`
log_stream_name = {instance_id}
file = /var/log/tomcat/access_log.*
commands:
"01":
command: systemctl enable awslogsd.service
"02":
command: systemctl restart awslogsd
```
[1]: https://codingrob.medium.com/how-to-setup-aws-elasticbeanstalk-to-stream-your-custom-application-logs-to-cloudwatch-d5c877eaa242
[2]: https://i.stack.imgur.com/yZSun.png