Chd.Library.Logging
8.6.5
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 utilities and helpers for managing schema updates, seeding and migration tasks.Supports:mssql,oracle,postgresql,sqllite |
|
|
Chd.Library.Core
Core primitives and shared building blocks for CHD projects: logging integration, configuration and common abstractions. |
|
|
Chd.Library.Web.Socket
WebSocket helpers and server/client abstractions for real-time messaging and socket-based communications. |
|
|
Chd.Library.MQTT
MQTT helpers and client wrappers for IoT and lightweight pub/sub messaging scenarios. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.6.5 | 110 | 1/20/2026 |
| 8.6.4 | 166 | 1/15/2026 |
| 8.6.3 | 124 | 1/12/2026 |
| 8.6.2 | 325 | 12/20/2025 |
| 8.6.1 | 313 | 12/19/2025 |
| 8.6.0 | 256 | 12/19/2025 |
| 8.5.9 | 280 | 12/18/2025 |
| 8.5.7 | 274 | 12/18/2025 |
| 8.5.6 | 283 | 12/18/2025 |
| 8.5.5 | 277 | 12/18/2025 |
| 8.5.4 | 214 | 10/24/2025 |
| 8.5.3 | 274 | 8/17/2025 |
| 8.1.8 | 322 | 12/17/2025 |