Chd.Library.Logging 8.0.9

There is a newer version of this package available.
See the version list below for details.
dotnet add package Chd.Library.Logging --version 8.0.9                
NuGet\Install-Package Chd.Library.Logging -Version 8.0.9                
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.0.9" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Chd.Library.Logging --version 8.0.9                
#r "nuget: Chd.Library.Logging, 8.0.9"                
#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.
// Install Chd.Library.Logging as a Cake Addin
#addin nuget:?package=Chd.Library.Logging&version=8.0.9

// Install Chd.Library.Logging as a Cake Tool
#tool nuget:?package=Chd.Library.Logging&version=8.0.9                

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

✍️ 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last updated
9.1.7 73 1/30/2025
9.1.6 73 1/19/2025
9.1.3 87 1/11/2025
9.1.2 76 1/11/2025
9.1.1 107 1/1/2025
8.0.9 152 12/23/2024
7.4.1 1,028 8/25/2023
7.4.0 590 8/18/2023
1.3.8 472 6/15/2023