LoggerHealthCheck 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package LoggerHealthCheck --version 1.0.0                
NuGet\Install-Package LoggerHealthCheck -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LoggerHealthCheck" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LoggerHealthCheck --version 1.0.0                
#r "nuget: LoggerHealthCheck, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// 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

NuGet version run unit tests Coverage Status GitHub license

Report Bug
Request Feature

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 Warnings have been logged in the last 5 minutes, if any Errors or Criticals 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

  1. At the Global level When calling AddHealthCheckLogger() you can provide a HealthCheckLoggerProviderConfiguration instance, this allows you to specify a custom filtration, you should allways include Filters.DefaultGlobalFilter otherwise you might get a endless loop.
  2. 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)

See LoggerHealthCheckOptions

Example

A example can be found in the Example directory.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 432 3/22/2021
1.0.1 332 3/17/2021
1.0.0 302 3/15/2021

1.0.0
Initial version