DiagnosKit.Core
2.1.3
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package DiagnosKit.Core --version 2.1.3
NuGet\Install-Package DiagnosKit.Core -Version 2.1.3
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="DiagnosKit.Core" Version="2.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DiagnosKit.Core" Version="2.1.3" />
<PackageReference Include="DiagnosKit.Core" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DiagnosKit.Core --version 2.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DiagnosKit.Core, 2.1.3"
#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.
#:package DiagnosKit.Core@2.1.3
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DiagnosKit.Core&version=2.1.3
#tool nuget:?package=DiagnosKit.Core&version=2.1.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
DiagnosKit.Core
A lightweight diagnostics toolkit for .NET 8+ that provides:
- Unified global exception handling (middleware)
- Structured logging with Serilog
- Elasticsearch sink support
- Easy integration for both Web APIs and Worker Services
📦 Installation
Install from NuGet:
dotnet add package DiagnosKit.Core
🚀 Usage
1. Web API (Program.cs
)
using DiagnosKit.Core;
// For pre-bootstrap logging
SerilogBootstrapper.UseBootstrapLogger();
var builder = WebApplication.CreateBuilder(args);
// Configure Serilog + Elasticsearch
builder.Host.ConfigureSerilogESSink();
// Add DiagnosKit logging abstraction
builder.Services.AddLoggerManager();
builder.Services.AddControllers();
var app = builder.Build();
// Use global exception handler middleware
app.UseUnifiedErrorHandler();
app.MapControllers();
app.Run();
2. Worker Service (Program.cs
)
using DiagnosKit.Core;
// For pre-bootstrap logging
SerilogBootstrapper.UseBootstrapLogger();
var builder = Host.CreateApplicationBuilder(args);
// Configure Serilog + Elasticsearch
builder.ConfigureSerilogESSink();
// Add DiagnosKit logging abstraction
builder.Services.AddLoggerManager();
// Add your worker
builder.Services.AddHostedService<MyWorker>();
var host = builder.Build();
host.Run();
Example Worker:
public class MyWorker : BackgroundService
{
private readonly ILoggerManager _logger;
public MyWorker(ILoggerManager logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
_logger.LogInfo("Worker started");
while (!stoppingToken.IsCancellationRequested)
{
_logger.LogDebug("Heartbeat at: {time}", DateTimeOffset.Now);
await Task.Delay(1000, stoppingToken);
}
}
}
⚙️ Configuration
IndexFormat will default to this format: application-name-{0:yyyy.MM}, if no format is specified
In your appsettings.json
:
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft.AspNetCore": "Information",
"System": "Warning"
}
}
},
"ElasticSearch": {
"Url": "http://localhost:9200",
"IndexFormat": "myapp-{0:yyyy.MM}"
},
}
📝 Features
- Web API support via middleware (
app.UseUnifiedErrorHandler()
). - Worker Service support with logger abstraction (
ILoggerManager
). - Serilog + Elasticsearch integration out of the box.
- Environment-aware index naming (per app + environment).
📊 Kibana Filtering
Because logs are enriched with structured properties (like Environment
, Service
, CorrelationId
, and Exception
),
you can filter/search logs in Kibana by:
Environment: "Production"
Service: "UserService"
Exception exists
UserId: 12345
⚖ License
This project is licensed under the MIT License - see the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- API.Common.Response.Models (>= 1.0.2)
- Microsoft.AspNetCore.Diagnostics.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.3)
- Serilog (>= 4.3.0)
- Serilog.AspNetCore (>= 8.0.0)
- Serilog.Enrichers.ClientInfo (>= 2.3.0)
- Serilog.Enrichers.CorrelationId (>= 3.0.1)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Enrichers.Process (>= 3.0.0)
- Serilog.Enrichers.Thread (>= 4.0.0)
- Serilog.Exceptions (>= 8.4.0)
- Serilog.Sinks.Console (>= 5.0.1)
- Serilog.Sinks.Debug (>= 2.0.0)
- Serilog.Sinks.Elasticsearch (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.