Add logging

Set up the ValuesController to log requests to the API methods by adding/updating the following code:

Add the following using statement:

using Microsoft.Extensions.Logging;

Inject ILogger into constructor:

private ILogger<ValuesController> _logger;

public ValuesController(ILogger<ValuesController> logger)
{
    _logger = logger; //inject logger
}

Set up the ValuesController to log requests to the API methods by adding the following code at the beginning of the Get method:

// GET api/values
[HttpGet]
public IEnumerable<string> Get()
{
    _logger.LogInformation(
        string.Format(">>>>>>>>>> ValuesController Get() Request from {0}", Request.HttpContext.Connection.RemoteIpAddress));

    return new string[] { "value1", "value2" };
}

Update the method Post to log a message to CloudWatch also:

// POST api/values
[HttpPost]
public void Post([FromBody]string value)
{
    _logger.LogInformation(
        string.Format(">>>>>>>>>> ValuesController Post() Request from {0}", Request.HttpContext.Connection.RemoteIpAddress));
}