Chd.Library.Logging
9.1.1
See the version list below for details.
dotnet add package Chd.Library.Logging --version 9.1.1
NuGet\Install-Package Chd.Library.Logging -Version 9.1.1
<PackageReference Include="Chd.Library.Logging" Version="9.1.1" />
paket add Chd.Library.Logging --version 9.1.1
#r "nuget: Chd.Library.Logging, 9.1.1"
// Install Chd.Library.Logging as a Cake Addin #addin nuget:?package=Chd.Library.Logging&version=9.1.1 // Install Chd.Library.Logging as a Cake Tool #tool nuget:?package=Chd.Library.Logging&version=9.1.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
I'm computer engineer for 14 years. I wrote this package for logging asp.net core applications. This logging machenism is use aspects for sipmlfy code.
🏁 Getting Started
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.
Prerequisites
You must use .net core 9.0 or higher
- Install graylog server.
🔧 Running the tests
[TestClass]
public class LoggingTests
{
static LoggingTests()
{
// ==> app.UseLogger(); //In project usings
LoggingDependencyInjectionExtensions.UseLogger(null);
}
[TestMethod]
public void Test()
{
var result = Sum(2, 0);
}
[TestMethod]
public void TestManuelLogging()
{
try
{
var result = Sum(2, 0);
Logger.LogInformation(result.ToString(), "Some Topic..");
}
catch (Exception ex)
{
Logger.LogError(ex.Message,"Some Topic..");
}
}
[Logged]
public int Sum(int a, int b)
{
return a + b;
}
}
Apsettings Configurations
You must add code below in appsettings.json
"LogConfig": {
"Server": "192.168.x.x", //required ip for graylog server
"Port": "xxxx", //graylog server port
"Path": "C:\\Logs\\LibrarySampleApp1\\log.txt",
"PathFormat": "C:\\Logs\\LibrarySampleApp1\\log-{Date}.txt",
"ApplicationName": "Library"
},
Test Result
Test result is shown on graylog UI. You can see running method name and included class name with method parameters value. 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.
🎈 Usage
Firstly you must call UseLogger method ("app.UseLogger();") in the program.cs file. 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.
⛏️ 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 | net9.0 is compatible. 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. |
-
net9.0
- Chd.Library.Common (>= 9.0.8)
- MethodBoundaryAspect.Fody (>= 2.0.149)
- 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 (>= 3.1.1)
- Serilog.Enrichers.Environment (>= 2.3.0)
- Serilog.Settings.Configuration (>= 8.0.0)
- Serilog.Sinks.File (>= 5.0.0)
- Serilog.Sinks.Graylog (>= 3.1.1)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Chd.Library.Logging:
Package | Downloads |
---|---|
Chd.Library.Core
The library written for .net core framework |
|
Chd.Library.Web.Socket
The library written for .net core framework |
|
Chd.Library.MQTT
The library written for .net core framework |
GitHub repositories
This package is not used by any popular GitHub repositories.