Po.Logging 1.0.0

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

// Install Po.Logging as a Cake Tool
#tool nuget:?package=Po.Logging&version=1.0.0                

Po's Logging System

I am trying to build a log system for small(medium) level product. At begging, I want to build a log system for the sake of learning dotnet log system. And I realized that this custom log could be used in some small project. I will upload the code after adding some comment.

rules

  • Even if you set the default log level to trace, the minimum level for logging database is Information
  • If you set the default level to trace, the console will log details include the following
    • Request Header
    • Request Body
    • Response Header
    • Response Body
  • If you set the default level to Debug, the console will log the stack trace, it will help you find the bug

Simple Guid to use the system

This log system need a postgres database with the following table

CREATE TABLE LOG (
  id                   BIGSERIAL  PRIMARY KEY,
  event_id             INTEGER    DEFAULT 0,
  event_name           TEXT,
  log_level            TEXT,
  path                 TEXT,
  message              TEXT,
  exception_type       TEXT,
  exception_message    TEXT,
  metadata             json,
  created_at           TIMESTAMPTZ DEFAULT NOW()
);

In the configuration file we need a connection string called 'Log'

"ConnectionStrings": {
"Log": "The connection string for the postgres database which contain log level"
}

And you also need the Logging section in your app setting file, especially for the default option

"Logging": {
    "LogLevel": {
      "Default": "Debug",
      "Microsoft.AspNetCore": "Error"
    }
}

So, the example for the app setting file would be

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.Hosting.LifeTime": "Information",
      "Microsoft.Extensions.Hosting.Internal.Host": "Error"
    }
  },
  "ConnectionStrings": {
    "Log": "..."
  }
}
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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 118 7/4/2024

First Release!!