Chd.Library.Logging 8.6.5

There is a newer version of this package available.
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
                    
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 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