LoggerHealthCheck 1.0.0
See the version list below for details.
dotnet add package LoggerHealthCheck --version 1.0.0
NuGet\Install-Package LoggerHealthCheck -Version 1.0.0
<PackageReference Include="LoggerHealthCheck" Version="1.0.0" />
paket add LoggerHealthCheck --version 1.0.0
#r "nuget: LoggerHealthCheck, 1.0.0"
// Install LoggerHealthCheck as a Cake Addin #addin nuget:?package=LoggerHealthCheck&version=1.0.0 // Install LoggerHealthCheck as a Cake Tool #tool nuget:?package=LoggerHealthCheck&version=1.0.0
LoggerHealthCheck
Table of Contents
About The Project
Project allows you to have a HealthCheck that changes status based on if a Warning, Error or Critical event is logged.
Getting Started
In Startup.ConfigureServices
add
services.AddHealthChecks()
.AddLoggerHealthCheck();
This will add a healtcheck named Logs
that will have the status Degraded
if any Warning
s have been logged in the last 5 minutes, if any Error
s or Critical
s have been logged it will have the status Unhealthy
.
With Serilog
In Program.cs
add
.ConfigureLogging(builder => builder.AddHealthCheckLogger())
.UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration.ReadFrom.Configuration(hostingContext.Configuration), writeToProviders: true)
Without Serilog
In Program.cs
add
.ConfigureLogging(builder => {
builder.AddHealthCheckLogger();
})
Customization
Healtcheck for specific class
If you want to add a specific HealthCheck for one class you can use the .AddLoggerHealthCheckForType<T>()
method in Startup.ConfigureServices
this will scan for log entries that either have source set as T
, or where a Exception's stacktrace contains the type.
Custom filtration
Filtration can be done at two diffrent levels
- At the Global level
When calling
AddHealthCheckLogger()
you can provide a HealthCheckLoggerProviderConfiguration instance, this allows you to specify a custom filtration, you should allways includeFilters.DefaultGlobalFilter
otherwise you might get a endless loop. - At HealthCheck level
When calling
AddLoggerHealthCheck()
you can provide a LoggerHealthCheckOptions instance, this allows you to specify a specific filter for that specific HealthCheck.
Configuration
Global (AddHealthCheckLogger)
See HealthCheckLoggerProviderConfiguration
HealthCheck specific (AddLoggerHealthCheck)
Example
A example can be found in the Example directory.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 5.0.4)
- Microsoft.Extensions.Logging (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
1.0.0
Initial version