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
<PackageReference Include="Chd.Library.Logging" Version="10.2.1" />
<PackageVersion Include="Chd.Library.Logging" Version="10.2.1" />
<PackageReference Include="Chd.Library.Logging" />
paket add Chd.Library.Logging --version 10.2.1
#r "nuget: Chd.Library.Logging, 10.2.1"
#:package Chd.Library.Logging@10.2.1
#addin nuget:?package=Chd.Library.Logging&version=10.2.1
#tool nuget:?package=Chd.Library.Logging&version=10.2.1
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
- Getting Started
- Bug Fixes For Previous Versions
- Prerequisites
- Injection Logger Into The Project For Logging
- Usage
- Apsettings Configurations
- Test Result
- Authors
- Acknowledgments
๐ง 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
- Graylog - Graylog server
โ๏ธ Authors
- Mehmet Yoldaล - Linkedin
See also the list of contributors who participated in this project.
๐ Acknowledgements
Thank you for using my library.
| Product | Versions 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. |
-
net10.0
- Chd.Library.Common (>= 10.2.1)
- MethodBoundaryAspect.Fody (>= 2.0.150)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.RazorPages (>= 2.3.0)
- Microsoft.AspNetCore.Mvc.ViewFeatures (>= 2.3.0)
- Microsoft.Extensions.Configuration.CommandLine (>= 10.0.1)
- Microsoft.Extensions.Configuration.Json (>= 10.0.1)
- Microsoft.Extensions.Hosting (>= 10.0.1)
- Newtonsoft.Json (>= 13.0.4)
- 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 | 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 |