![]() |
VOOZH | about |
dotnet add package Pr.BuildingBlocks.Cms.Logging --version 1.2.0
NuGet\Install-Package Pr.BuildingBlocks.Cms.Logging -Version 1.2.0
<PackageReference Include="Pr.BuildingBlocks.Cms.Logging" Version="1.2.0" />
<PackageVersion Include="Pr.BuildingBlocks.Cms.Logging" Version="1.2.0" />Directory.Packages.props
<PackageReference Include="Pr.BuildingBlocks.Cms.Logging" />Project file
paket add Pr.BuildingBlocks.Cms.Logging --version 1.2.0
#r "nuget: Pr.BuildingBlocks.Cms.Logging, 1.2.0"
#:package Pr.BuildingBlocks.Cms.Logging@1.2.0
#addin nuget:?package=Pr.BuildingBlocks.Cms.Logging&version=1.2.0Install as a Cake Addin
#tool nuget:?package=Pr.BuildingBlocks.Cms.Logging&version=1.2.0Install as a Cake Tool
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.
Sentry.AspNetCore) — aktywowane wyłącznie gdy ustawiony jest DSN.
ASPNETCORE_ENVIRONMENT (poprawne tagowanie per klaster).BaseException i pochodne z Pr.BuildingBlocks.Cms.Core) — nie zalewają Sentry błędami 4xx.SendDefaultPii=false, MaxRequestBodySize=None, TracesSampleRate=0.05, MinimumEventLevel=Warning.Sentry.Profiling) sterowany flagą EnableProfiling (+ ProfilesSampleRate > 0).simple w Development, ze scope'ami i znacznikiem UTC. Ustawiane jako nadpisywalny default.Logging:LogLevel:Default = Warning dla całej aplikacji: wycisza wszystkie logi Information (framework, EF Core SQL, messaging Wolverine, kod aplikacji); zostają Warning+. Nadpisywalny default; wyłączany flagą EnableDefaultLogLevels.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();
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.
// 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.
Sentry.AspNetCore, Sentry.ProfilingPr.BuildingBlocks.Cms.Core (kontrakt BaseException)Microsoft.AspNetCore.App (shared framework)| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.