Part 6 - View Application Logs in CloudWatch Logs

Finally, view the logs that were generated with the code you added to the ValuesController by following the steps below.

1. In the AWS Management console, navigate to the CloudWatch console.

2. On the CloudWatch console, click Logs in the left-side menu to view the log groups.

3. Find the DotNetWebApiLab log group. If you have many log groups in your account, you can search for the group by name in the filter box.

4. Click on the DotNetWebApiLab log group, and you should see one or more log streams. A log stream represents the sequence of events coming from an application instance or resource that you are monitoring; in this case, the EC2 instance running the Web API application.

5. Click on one of the log streams, and find the log entries written by the ValuesController.

You should see log entries covering the lifetime of requests to the API, similar to the below. Because the logging in appsettings.json is configured to “information”, many events were logged. Look for the messages logged from the code you added, for the GET and POST requests.

Request starting HTTP/1.1 GET

Executing action method WebApiChallenge.Controllers.ValuesController.Get (WebApiChallenge) with arguments ((null)) - ModelState is Valid

ValuesController Get() Request from

Executing ObjectResult, writing value Microsoft.AspNetCore.Mvc.ControllerContext

Executed action WebApiChallenge.Controllers.ValuesController.Get (WebApiChallenge)

Request finished in 193.22ms 200 application/json; charset=utf-8

Request starting HTTP/1.1 POST

Executing action method WebApiChallenge.Controllers.ValuesController.Post (WebApiChallenge) with arguments () - ModelState is Invalid

ValuesController Post() Request from

Executed action WebApiChallenge.Controllers.ValuesController.Post (WebApiChallenge)

Request finished in 47.133ms 200

Congratulations, you have created and deployed an ASP.NET Web API application using AWS Elastic Beanstalk, created and configured API Gateway as a proxy in front of your API with throttling, and then confirmed that the throttling is enforced using a PowerShell script or Postman.