Common.Logging.Lib
1.0.2
dotnet add package Common.Logging.Lib --version 1.0.2
NuGet\Install-Package Common.Logging.Lib -Version 1.0.2
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="Common.Logging.Lib" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Common.Logging.Lib" Version="1.0.2" />
<PackageReference Include="Common.Logging.Lib" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Common.Logging.Lib --version 1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Common.Logging.Lib, 1.0.2"
#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.
#:package Common.Logging.Lib@1.0.2
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Common.Logging.Lib&version=1.0.2
#tool nuget:?package=Common.Logging.Lib&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Here’s a README.md file for your Common.Logging .NET 8 project:
Common.Logging for .NET 8
This project provides a common logging configuration for .NET 8 applications, utilizing Serilog for structured logging.
Features
- Serilog Integration: Configures Serilog with JSON-formatted logs.
- Console Logging: Outputs logs to both stdout and stderr.
- Log Context Enrichment: Adds contextual information to logs.
- Configurable Log Levels: Allows dynamic configuration from
appsettings.json.
Installation
Install required NuGet packages:
dotnet add package Serilog.AspNetCore dotnet add package Serilog.Settings.Configuration dotnet add package Serilog.Sinks.ConsoleAdd logging configuration to
appsettings.json:{ "Serilog": { "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Information" } }, "WriteTo": [ { "Name": "Console", "Args": { "formatter": "Serilog.Formatting.Json.JsonFormatter" } } ], "Enrich": ["FromLogContext"] } }
Usage
Add the logging configuration to your Program.cs:
using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
using Serilog.Formatting.Json;
public static class LoggingExtensions
{
public static IHostBuilder UseUniversalLogging(this IHostBuilder hostBuilder)
{
hostBuilder.UseSerilog((context, services, loggerConfiguration) =>
{
loggerConfiguration
.ReadFrom.Configuration(context.Configuration)
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Console(new JsonFormatter()) // Writes logs to console
.WriteTo.Console(new JsonFormatter(), standardErrorFromLevel: LogEventLevel.Verbose); // Writes logs to stdout
});
return hostBuilder;
}
}
Then, apply it in Program.cs:
var builder = Host.CreateDefaultBuilder(args)
.UseUniversalLogging();
Deployment Notes
- Ensure your logging configuration is correctly set in
appsettings.jsonor environment variables. - In Kubernetes environments, logs will be structured in JSON for better compatibility with log aggregators like Fluentd or Loki.
Contributing
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch - Commit changes:
git commit -m "Added new feature" - Push and create a PR.
Let me know if you need any modifications! 🚀
| 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. 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. net10.0 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Serilog (>= 4.2.0)
- Serilog.AspNetCore (>= 8.0.1)
- Serilog.Extensions.Hosting (>= 9.0.0)
- Serilog.Settings.Configuration (>= 9.0.0)
- Serilog.Sinks.Console (>= 5.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.