HealthCheck forcefully logs error on HealthCheckResult.Unhealthy
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Describe the bug
When implementing a health check using the IHealthCheck interface, the service enters a "shutting down" state where it completes its current tasks before stopping. During this state, the health check returns an "unhealthy" status to prevent the service from accepting new tasks. However, this results in the health check repeatedly logging errors, which in turn triggers alerts.
### Expected Behavior
The health check should return "unhealthy" to prevent new tasks from being assigned to the service.
The system should handle the "unhealthy" status gracefully without repeatedly logging errors or triggering alert
### Steps To Reproduce
Implement a health check using the IHealthCheck interface.
Initiate the service and allow it to process tasks.
Transition the service into a "shutting down" state where it completes ongoing tasks and then stops.
Observe the health check status during the "shutting down" state.
### Exceptions (if any)
I should be able to configure the log level.
### .NET Version
8.0.300
### Anything else?
Fake errors:

Contributor guide
Assessment
This issue has not been assessed yet.