GamersCommunity.Core.Logging 3.0.0

dotnet add package GamersCommunity.Core.Logging --version 3.0.0
                    
NuGet\Install-Package GamersCommunity.Core.Logging -Version 3.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="GamersCommunity.Core.Logging" Version="3.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="GamersCommunity.Core.Logging" Version="3.0.0" />
                    
Directory.Packages.props
<PackageReference Include="GamersCommunity.Core.Logging" />
                    
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 GamersCommunity.Core.Logging --version 3.0.0
                    
#r "nuget: GamersCommunity.Core.Logging, 3.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.
#:package GamersCommunity.Core.Logging@3.0.0
                    
#: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=GamersCommunity.Core.Logging&version=3.0.0
                    
Install as a Cake Addin
#tool nuget:?package=GamersCommunity.Core.Logging&version=3.0.0
                    
Install as a Cake Tool

GamersCommunity.Core.Logging

GamersCommunity.Core.Logging is the centralized logging subsystem of the GamersCommunity ecosystem.
It provides a production‑ready Serilog bootstrapper with advanced formatting, multi‑sink log level control, HTTP log separation, and strongly‑typed configuration settings.

Status: Work in progress.
External contributions are not actively solicited, but feedback and issue reports are welcome.


✨ Introduction

This package gives every GamersCommunity microservice, gateway, worker, or tool a consistent, configurable, structured logging layer without repeating the same setup.

It wraps Serilog with a standard configuration that includes:

  • Unified console formatting with custom colors
  • Automatic detection of HTTP logs (messages starting with HTTP)
  • Separated sub-loggers for HTTP and non-HTTP entries
  • Environment & application enrichment
  • Per‑sink minimum log levels (Console, File, Seq)
  • Daily file rotation
  • Seq integration (API key supported)
  • Strongly-typed settings (LoggerSettings / LogMinimumLevel)
  • Serilog internal diagnostics written to serilog_errors.txt

🚀 Getting Started

Requirements

  • .NET 10
  • Visual Studio 2022 / VS 2026 / Rider / VS Code

Installation

Install from your NuGet feed:

dotnet add package GamersCommunity.Core.Logging

⚙️ Usage

1. Add configuration to appsettings.json

{
  "Logger": {
    "MinimumLevel": {
      "Global": "Information",
      "ConsoleHttp": "Information",
      "ConsoleNotHttp": "Debug",
      "File": "Debug",
      "Seq": "Warning",
      "EntityFrameworkCore": "Warning"
    },
    "FilePath": "logs/log-.txt",
    "SeqPath": "http://localhost:5341",
    "SeqKey": ""
  }
}

All fields are optional — defaults are provided.


2. Bind settings + initialize logger (Program.cs)

var loggerSettings = builder.Configuration
    .GetSection("Logger")
    .Get<LoggerSettings>() ?? new LoggerSettings();

GamersCommunity.Core.Logging.Logger.Initialize(
    loggerSettings,
    applicationName: "MyService",
    environment: builder.Environment
);

builder.Host.UseSerilog();

🔧 Logger Settings Overview

LoggerSettings

Property Description
MinimumLevel Set of minimum log levels per sink
FilePath Path for rolling log files (optional)
SeqPath Seq server URL
SeqKey Seq API key (optional)

LogMinimumLevel

This class enables fine‑grained control over log levels per output target:

Property Applies to
Global Base global level for all logs
ConsoleHttp Console logs whose message begins with "HTTP"
ConsoleNotHttp Console logs not starting with "HTTP"
File Rolling file logs
Seq Seq logs
EntityFrameworkCore EF Core log level override

Default values:

{
  "Global": "Verbose",
  "ConsoleHttp": "Verbose",
  "ConsoleNotHttp": "Verbose",
  "File": "Debug",
  "Seq": "Information",
  "EntityFrameworkCore": "Warning"
}

🎨 Console Output Formatting

Non‑HTTP logs

[21/11/2025 10:45:12 - Information] [Env:Development] [App:Gateway] - Service started successfully

HTTP logs

[21/11/2025 10:45:12 - Information] [Env:Production] [App:Gateway] [Ip:127.0.0.1] [Sender:User42] [UserId:7] - HTTP GET /api/users/7 => 200

Colors adapt by level thanks to the custom SystemConsoleTheme.


📦 File Logging

When FilePath is defined, logs are written to:

logs/log-20251121.txt

Features:

  • Daily rolling files
  • 7‑day retention
  • Custom minimum level via MinimumLevel.File

📡 Seq Logging

Enable by setting:

"SeqPath": "https://seq.mydomain.com",
"SeqKey": "MY-API-KEY"

Supports:

  • Minimum level override
  • API key authentication
  • Fully structured events

🪲 Serilog Internal Diagnostics

Internal Serilog errors (sink failures, formatting issues) are logged to:

serilog_errors.txt

Very useful when debugging permissions or Seq connectivity problems.


💬 Feedback

👉 Issues: https://github.com/Bari77/GamersCommunity.Core/issues

Bug reports and suggestions are always appreciated.


🤝 Contributing

PRs are not actively requested, but constructive feedback is welcome. To contribute:

  • Fork the repo
  • Create a branch
  • Open a Draft PR for discussion

The team may close PRs that don’t align with the roadmap.


🧩 Versioning

Breaking changes may occur before v1.0.


📜 License

A permissive license (MIT or similar) will be published soon.


🙌 Credits

Built with ❤️ by the GamersCommunity maintainers.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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
3.0.0 315 11/21/2025
2.0.0 290 11/21/2025
1.0.0 298 11/21/2025
0.0.2 230 8/29/2025
0.0.1 244 8/28/2025