Chd.Library.Logging 10.2.1

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

Logging library for .Net Core

Chd (cleverly handle difficulty) library helps you cleverly handle difficulty, writing code fastly and do your application stable.

๐Ÿ“ Table of Contents

๐Ÿง About

Logging is an important feature that finding the cause of problem. This package is very simple to use with aspect oriented programming. This library is sink graylog server. You can see logs on graylog run simple step below.

This library use compile time aspects

๐Ÿ Getting Started

We use "Logged" attribute for logging method.

๐Ÿ› ๏ธ Prerequisites

  • you must write
  • .NET 10 SDK (recommended) or higher
  • You must execute "NuGet\Install-Package MethodBoundaryAspect.Fody -Version 2.0.150" command on Package Manager Console
  • Having graylog server connection information

Bug Fixes For Previous Versions

This is version 8.6.2 is fixed some bugs. Async methods are now supported with powerful compile-time aspects. This is a major update that improves the stability and performance of the logging library. This asspect is very hight performans from runtime aspects. The performance value than runtime aspects is approximately 300% higher.

๐Ÿ’‰ Injection Logger Into The Project For Logging

Firstly you must call UseLogger method ("app.UseLogger();") in the program.cs file.

var builder = WebApplication.CreateBuilder(args);
   ....
   ....
   app.UseLogger();

๐ŸŽˆ Usage

You must use Logged attribute on method whice you want to loggging method. Do not forget adding graylog configuration in appsettings.json file. That's it, now you can see the logs of the methods in graylog by using the "logged" attribute in any class you want. You can also see the logs in the directory you specified in the appsettings.json file.

public class LoggingTestController : ControllerBase
    {
        public LoggingTestController()
        {

        }

        [Logged] //For logging method with parameters and return value.
        [Route("Sum")]
        [HttpGet]
        public int? Sum(int a,int b) //For testing on swagger or etc..
        {
            return a + b;
        }

        [Route("Sum")]
        [HttpGet]
        public int? Multiply(int a,int b) //For testing on swagger or etc..
        {
            Logger.LogInformation("Some information messages..."); //For manuel logging 
            return a * b;
        }
    }

Logging the "Sum" method includes compile-time aspects. Compile-time aspects are faster than run-time aspects because they are woven into the code during the build process, reducing the overhead during execution.

โš™๏ธ Apsettings Configurations

You must add code below in appsettings.json if you want to see lines numbers and file names in the logs, only you must add below PropertyGroup in your project file (.csproj).

	<PropertyGroup>
		<DebugType>portable</DebugType>
		<DebugSymbols>true</DebugSymbols>
		<IncludeSymbols>true</IncludeSymbols>
	</PropertyGroup>

you must add below configuration in appsettings.json file.

"LogConfig": {
    "ApplicationName": "Your_Application_Name",
    "Sink": "MSSql",//You can use "Graylog" or "MSSql" or "File"
    "SinkDBConnectionString": "db connection string",//If you use "MSSql" sink, you must enter your database connection string.
    "SinkTableName": "ApplicationLogs"
    "Server": "localhost", // if you use "Graylog" sink, you must enter your graylog server address.
    "Port": "3003", //if you use "Graylog" sink, you must enter your graylog server port.
    "Path": "C:\\Logs\\Your_Application_Name\\log.txt", // 
    "PathFormat": "C:\\Logs\\Your_Application_Name\\log-{Date}.txt"
  },

๐Ÿ“‘ Test Result

Test result is shown on graylog UI. You can see running method name and included class name with method parameters value. Enter 4 and 7 values in Sum method using swagger. Then look at the greaylog UI. You should see below logs.

  • The LoggingTestController.Sum method started working with "[4,7]" parameters.
  • The LoggingTestController.Sum method successfully completed its work by returning the result of 11 with the "[4,7]" input parameters. If user logged in the application, you can see who user used the application. If method crashed you can see why the method crashed. Sometime method crashed for some invalid parameters. You can calculate error reason.
  • Graylog UI screen shot for this log

โ›๏ธ Built Using

โœ๏ธ Authors

See also the list of contributors who participated in this project.

๐ŸŽ‰ Acknowledgements

Thank you for using my library.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 41 1/15/2026
10.2.0 157 12/21/2025
9.2.0 42 1/15/2026
9.1.9 149 12/27/2025
9.1.7 299 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.4 48 1/15/2026
8.6.3 113 1/12/2026
8.6.2 281 12/20/2025
8.6.1 305 12/19/2025
8.6.0 248 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 268 12/18/2025
8.5.4 204 10/24/2025
8.5.3 260 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 610 12/23/2024
8.0.1 828 2/3/2024
8.0.0 569 1/30/2024
7.4.1 1,143 8/25/2023
7.4.0 673 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 688 6/13/2023
1.3.4 642 6/13/2023
1.3.3 880 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 644 4/28/2023
1.2.8 1,378 2/9/2023
1.2.7 2,563 1/30/2023
1.1.9 3,613 1/30/2023