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
                    
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="Chd.Library.Logging" Version="8.6.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Chd.Library.Logging" Version="8.6.5" />
                    
Directory.Packages.props
<PackageReference Include="Chd.Library.Logging" />
                    
Project file
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 Chd.Library.Logging --version 8.6.5
                    
#r "nuget: Chd.Library.Logging, 8.6.5"
                    
#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 Chd.Library.Logging@8.6.5
                    
#: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=Chd.Library.Logging&version=8.6.5
                    
Install as a Cake Addin
#tool nuget:?package=Chd.Library.Logging&version=8.6.5
                    
Install as a Cake Tool

Logging Library for .NET Core

NuGet License


📝 Table of Contents


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 Logger class
  • 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.

Graylog UI Screenshot


Authors

See also other contributors on NuGet.


Acknowledgements


For issues or feature requests, visit mehmet-yoldas/library-core

Product 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.

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
Loading failed