Chd.Library.Logging
8.6.5
See the version list below for details.
dotnet add package Chd.Library.Logging --version 8.6.5
NuGet\Install-Package Chd.Library.Logging -Version 8.6.5
<PackageReference Include="Chd.Library.Logging" Version="8.6.5" />
<PackageVersion Include="Chd.Library.Logging" Version="8.6.5" />
<PackageReference Include="Chd.Library.Logging" />
paket add Chd.Library.Logging --version 8.6.5
#r "nuget: Chd.Library.Logging, 8.6.5"
#:package Chd.Library.Logging@8.6.5
#addin nuget:?package=Chd.Library.Logging&version=8.6.5
#tool nuget:?package=Chd.Library.Logging&version=8.6.5
Logging Library for .NET Core
📝 Table of Contents
- About
- Features
- Installing
- Getting Started
- Configuration
- Usage
- Supported Sinks
- Test Results
- Authors
- Acknowledgements
About
Chd.Library.Logging enables high-performance, aspect-oriented and manual logging for .NET Core applications.
It supports Graylog, MS SQL, and File as log sinks.
Compile-time aspects (using MethodBoundaryAspect.Fody) minimize overhead and support async methods, providing log entries for parameters, return values, and user details.
Features
- Compile-time aspect logging via
[Logged]attribute (high-performance, supports async) - Manual logging via static
Loggerclass - Multiple log sinks: Graylog, MSSQL, File (configurable at runtime)
- All logs include method/class/parameter information and execution result
- See log entries in your preferred backend or local files
- .NET 9.0+
- Includes user information (where available)
- Supports seeing line number and file name in logs (debug symbols support)
Installing
dotnet add package Chd.Library.Logging
# Required for aspects:
dotnet add package MethodBoundaryAspect.Fody
Note: Compile-time aspect approach requires Fody.
Add the following to your.csproj:
<ItemGroup>
<PackageReference Include="MethodBoundaryAspect.Fody" Version="2.0.150" PrivateAssets="all" />
<WeaverInclude>MethodBoundaryAspect.Fody</WeaverInclude>
</ItemGroup>
Getting Started
1. Enable the logger in your API pipeline
In Program.cs:
var builder = WebApplication.CreateBuilder(args);
// ... register other services
var app = builder.Build();
app.UseLogger();
Configuration
A. Project file: Enable debug symbols for line/filename in logs
Add to your .csproj:
<PropertyGroup>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<IncludeSymbols>true</IncludeSymbols>
</PropertyGroup>
B. Logging config in appsettings.json
"LogConfig": {
"ApplicationName": "YourApp",
"Sink": "Graylog", // One of: "Graylog", "MSSql", "File"
"SinkDBConnectionString": "Data Source=...;", // for MSSql
"SinkTableName": "ApplicationLogs", // for MSSql
"Server": "localhost", // for Graylog
"Port": "3003", // for Graylog
"Path": "C:\\Logs\\YourApp\\log.txt", // for file sink
"PathFormat": "C:\\Logs\\YourApp\\log-{Date}.txt" // for file sink
}
- Multiple sinks are supported; logs go to the configured one.
Usage
Aspect-Oriented Logging
Just add [Logged] attribute to any method (controller or service):
using Chd.Library.Logging;
public class LoggingTestController : ControllerBase
{
public LoggingTestController() {}
[Logged] // Logs method, parameters, result, exceptions, user info, etc.
[Route("Sum")]
[HttpGet]
public int? Sum(int a, int b)
{
return a + b;
}
}
- No other code needed. All method calls, parameters, return values and failures are automatically logged at compile time.
- Performance is up to 3x faster than classic runtime/proxy aspects.
Manual Logging
You can still call logger manually, anytime:
using Chd.Library.Logging;
// Inside any class:
Logger.LogInformation("Custom info message...");
Logger.LogError("This went wrong!", exceptionObj);
Supported Sinks
- Graylog: for centralized, searchable log streams; set "Sink": "Graylog"
- MSSQL: logs to database table; set "Sink": "MSSql" and provide connection
- File: logs to local or shared file path(s); set "Sink": "File"
Test Results
- All logs can be seen instantly on Graylog UI, MSSQL (as rows) or file.
- Each log entry automatically includes:
- Method and parameters
- Return value/result (or exception)
- User info (if in context)
- Timestamp, file and line number (with debug symbols)
- Example event:
LoggingTestController.Sum method started with [4,7].
LoggingTestController.Sum returned 11 with [4,7].
Exception logs include error message, stacktrace and context.
Authors
See also other contributors on NuGet.
Acknowledgements
- Graylog
- MethodBoundaryAspect.Fody
- Thanks for using this library—issues and PRs are welcome!
For issues or feature requests, visit mehmet-yoldas/library-core
| 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. |
-
net8.0
- Chd.Library.Common (>= 8.5.6)
- MethodBoundaryAspect.Fody (>= 2.0.150)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Mvc.RazorPages (>= 2.2.5)
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.2.0)
- Microsoft.Extensions.Configuration.CommandLine (>= 8.0.0)
- Microsoft.Extensions.Configuration.Json (>= 8.0.0)
- Microsoft.Extensions.Hosting (>= 8.0.0)
- Newtonsoft.Json (>= 13.0.3)
- Serilog (>= 4.1.0)
- Serilog.Enrichers.Environment (>= 2.3.0)
- Serilog.Settings.Configuration (>= 8.0.0)
- Serilog.Sinks.File (>= 5.0.0)
- Serilog.Sinks.Graylog (>= 3.1.1)
- Serilog.Sinks.MSSqlServer (>= 8.2.2)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Chd.Library.Logging:
| Package | Downloads |
|---|---|
|
Chd.Library.Migrations
Database migration helpers using FluentMigrator: schema versioning and utilities to apply and manage database migrations. Supports optional apply‑on‑startup integration (IMigrationRunner.MigrateUp) so migrations can run automatically when the host starts. |
|
|
Chd.Library.Core
Core utilities and abstractions used across CHD projects — shared helpers, common services and infrastructure conveniences for building libraries and apps. |
|
|
Chd.Library.Web.Socket
WebSocket helpers and realtime server/client utilities: lightweight wrappers, connection management and message handling helpers for building realtime features. |
|
|
Chd.Library.MQTT
MQTT helpers and managed client utilities built on MQTTnet: connection and lifecycle management, managed client wrappers and convenience utilities for IoT messaging scenarios. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 10.2.1 | 88 | 1/15/2026 |
| 10.2.0 | 157 | 12/21/2025 |
| 9.2.0 | 91 | 1/15/2026 |
| 9.1.9 | 149 | 12/27/2025 |
| 9.1.7 | 300 | 1/30/2025 |
| 9.1.6 | 240 | 1/19/2025 |
| 9.1.3 | 220 | 1/11/2025 |
| 9.1.2 | 204 | 1/11/2025 |
| 9.1.1 | 230 | 1/1/2025 |
| 8.6.5 | 43 | 1/20/2026 |
| 8.6.4 | 99 | 1/15/2026 |
| 8.6.3 | 113 | 1/12/2026 |
| 8.6.2 | 286 | 12/20/2025 |
| 8.6.1 | 305 | 12/19/2025 |
| 8.6.0 | 249 | 12/19/2025 |
| 8.5.9 | 270 | 12/18/2025 |
| 8.5.7 | 266 | 12/18/2025 |
| 8.5.6 | 268 | 12/18/2025 |
| 8.5.5 | 269 | 12/18/2025 |
| 8.5.4 | 206 | 10/24/2025 |
| 8.5.3 | 262 | 8/17/2025 |
| 8.5.2 | 235 | 7/31/2025 |
| 8.5.1 | 650 | 7/23/2025 |
| 8.1.8 | 312 | 12/17/2025 |
| 8.0.9 | 635 | 12/23/2024 |
| 8.0.1 | 830 | 2/3/2024 |
| 8.0.0 | 569 | 1/30/2024 |
| 7.4.1 | 1,143 | 8/25/2023 |
| 7.4.0 | 674 | 8/18/2023 |
| 7.3.8 | 845 | 8/9/2023 |
| 1.3.8 | 581 | 6/15/2023 |
| 1.3.7 | 698 | 6/13/2023 |
| 1.3.6 | 689 | 6/13/2023 |
| 1.3.4 | 642 | 6/13/2023 |
| 1.3.3 | 881 | 5/28/2023 |
| 1.3.2 | 888 | 5/8/2023 |
| 1.3.1 | 643 | 5/8/2023 |
| 1.3.0 | 890 | 4/28/2023 |
| 1.2.9 | 645 | 4/28/2023 |
| 1.2.8 | 1,378 | 2/9/2023 |
| 1.2.7 | 2,563 | 1/30/2023 |
| 1.1.9 | 3,629 | 1/30/2023 |