Skip to content

Instantly share code, notes, and snippets.

@PatrickKalkman
Created June 20, 2021 17:46
Show Gist options
  • Save PatrickKalkman/e62786bdf855538ac55f688411d3bee0 to your computer and use it in GitHub Desktop.
Save PatrickKalkman/e62786bdf855538ac55f688411d3bee0 to your computer and use it in GitHub Desktop.
Adding logging to the health check controller
[ApiController]
[Route("[controller]")]
public class HealthCheckController : ControllerBase
{
private readonly ILogger<HealthCheckController> _logger;
public HealthCheckController(ILogger<HealthCheckController> logger)
{
_logger = logger;
}
[HttpGet]
public IActionResult HealthCheck()
{
_logger.LogInformation("Performing health check");
// Check the health of your application
// e.g. perform query on the database and map the result
return Ok();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment