1

I'm reading the documentation but I'm not understanding simple Java application log access via CloudWatch from AWS Elastic Beanstalk.

I have a simple Java Spring Boot Application deployed on Elastic Beanstalk as a JAR file using the Java Corretto 11 platform with HTTPS. It has successfully created an EC2 instance and a load balancer. I can access the web site via HTTPS. I can see simple access log statistics in the Elastic Beanstalk environment monitoring section.

But where do the Java logs go, and how can I look into them in CloudWatch?

The Using Elastic Beanstalk with Amazon CloudWatch Logs documentation seems to be about the legacy CloudWatch Logs agent, not the new unified CloudWatch agent. Whatever the case, that page says:

Elastic Beanstalk configures log groups in CloudWatch Logs for the various log files that it streams.

But in CloudWatch Logs I have no log groups. So something is wrong already.

My Spring Boot JAR application is running on Elastic Beanstalk. What are my next steps to view the Spring Boot logs in CloudWatch Logs?

Garret Wilson
  • 165
  • 2
  • 13

1 Answers1

1

The secret is that for the AWS Elastic Beanstalk environment, under Configuration there is a section "Instance log streaming to CloudWatch Logs". The setting Log streaming must be enabled.

This is alluded to in the Using Elastic Beanstalk with Amazon CloudWatch Logs documentation (emphasis added):

When you enable instance log streaming to CloudWatch Logs, Elastic Beanstalk sends log files from your environment's instances to CloudWatch Logs.

Garret Wilson
  • 165
  • 2
  • 13
  • this still doesnt send for example tomcat logs from your environment to cloudwatch.It only sends the standard logs such as any nginx access logs etc. – whokares Apr 29 '21 at 18:28
  • @whokares Refer to the [Custom log file streaming](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.cloudwatchlogs.html#AWSHowTo.cloudwatchlogs.streaming.custom) section of that documentation. You will need to add an .ebextensions config file to your deployment specifying the location of your app logs – Cavyn VonDeylen Jun 01 '21 at 18:51