Created
June 20, 2021 17:46
-
-
Save PatrickKalkman/e62786bdf855538ac55f688411d3bee0 to your computer and use it in GitHub Desktop.
Adding logging to the health check controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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