Pr.BuildingBlocks.Cms.Logging 1.0.0

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

Pr.BuildingBlocks.Cms.Logging

Współdzielona konfiguracja obserwowalności dla mikroserwisów CMS: Sentry + structured console logging, z bezpiecznymi domyślnymi wartościami nadpisywalnymi przez appsettings.json lub kod.

Co dostarcza

  • Sentry (Sentry.AspNetCore) — aktywowane wyłącznie gdy ustawiony jest DSN.
    • Środowisko wyprowadzane z ASPNETCORE_ENVIRONMENT (poprawne tagowanie per klaster).
    • Filtr odrzucający spodziewane wyjątki biznesowe (BaseException i pochodne z Pr.BuildingBlocks.Cms.Core) — nie zalewają Sentry błędami 4xx.
    • Bezpieczne domyślne: SendDefaultPii=false, MaxRequestBodySize=None, TracesSampleRate=0.05, MinimumEventLevel=Error.
    • Opcjonalny profiling (Sentry.Profiling) sterowany flagą EnableProfiling (+ ProfilesSampleRate > 0).
  • Structured console logging — JSON na produkcji (parsowalne w log aggregation), czytelny simple w Development, ze scope'ami i znacznikiem UTC. Ustawiane jako nadpisywalny default.

Użycie

using Pr.BuildingBlocks.Cms.Logging;

var builder = WebApplication.CreateBuilder(args);

// Domyślna konfiguracja; DSN brany z Sentry:Dsn / Sentry__Dsn.
builder.AddObservability();

var app = builder.Build();

// Middleware tracingu Sentry (no-op gdy Sentry nieaktywne).
app.UseObservability();

Nadpisywanie domyślnych

Precedencja (od najniższej): domyślne z kodu → sekcja Sentry w appsettings.json → callback.

1. Przez appsettings.json (sekcja Sentry; structured console przez Logging:Console):

{
  "Sentry": {
    "Dsn": "https://...@sentry.io/...",
    "TracesSampleRate": 0.2
  },
  "Logging": {
    "Console": { "FormatterName": "simple" }
  }
}

W prod DSN zwykle podajesz przez Sentry__Dsn.

2. Przez kod (najwyższy priorytet):

builder.AddObservability(options =>
{
    options.TracesSampleRate = 0.2;
    options.EnableProfiling = true;
    options.ProfilesSampleRate = 0.1;
});

Walidacja (TracesSampleRate/ProfilesSampleRate w [0,1], MaxBreadcrumbs >= 0, profiling wymaga dodatniego sample rate) rzuca ArgumentException z jasnym komunikatem na etapie rejestracji.

API

// Konfiguracja (Program.cs, przed Build()).
public static WebApplicationBuilder AddObservability(
    this WebApplicationBuilder builder,
    Action<LoggingOptions>? configure = null);

// Pipeline (po Build()).
public static WebApplication UseObservability(this WebApplication app);

Pełna lista ustawień (nazwy property = klucze sekcji Sentry): zob. LoggingOptions.

Zależności

  • Sentry.AspNetCore, Sentry.Profiling
  • Pr.BuildingBlocks.Cms.Core (kontrakt BaseException)
  • Microsoft.AspNetCore.App (shared framework)
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
1.0.0 61 6/16/2026