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" />
                    
Directory.Packages.props
<PackageReference Include="Common.Logging.Lib" />
                    
Project file
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
                    
#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
                    
Install as a Cake Addin
#tool nuget:?package=Common.Logging.Lib&version=1.0.2
                    
Install as a Cake Tool

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

  1. Install required NuGet packages:

    dotnet add package Serilog.AspNetCore
    dotnet add package Serilog.Settings.Configuration
    dotnet add package Serilog.Sinks.Console
    
  2. Add 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.json or environment variables.
  • In Kubernetes environments, logs will be structured in JSON for better compatibility with log aggregators like Fluentd or Loki.

Contributing

  1. Fork the repository.
  2. Create a new branch: git checkout -b feature-branch
  3. Commit changes: git commit -m "Added new feature"
  4. Push and create a PR.

Let me know if you need any modifications! 🚀

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

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.2 198 5/8/2025
1.0.1 114 11/8/2024
1.0.0 152 11/8/2024