Po.Logging
1.0.0
dotnet add package Po.Logging --version 1.0.0
NuGet\Install-Package Po.Logging -Version 1.0.0
<PackageReference Include="Po.Logging" Version="1.0.0" />
paket add Po.Logging --version 1.0.0
#r "nuget: Po.Logging, 1.0.0"
// 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 | Versions 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. |
-
net8.0
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.0)
- Microsoft.Extensions.Configuration.Json (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- Microsoft.Extensions.Options (>= 8.0.0)
- Npgsql (>= 8.0.3)
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!!