Logging.Client
1.9.0
dotnet add package Logging.Client --version 1.9.0
NuGet\Install-Package Logging.Client -Version 1.9.0
<PackageReference Include="Logging.Client" Version="1.9.0" />
<PackageVersion Include="Logging.Client" Version="1.9.0" />
<PackageReference Include="Logging.Client" />
paket add Logging.Client --version 1.9.0
#r "nuget: Logging.Client, 1.9.0"
#:package Logging.Client@1.9.0
#addin nuget:?package=Logging.Client&version=1.9.0
#tool nuget:?package=Logging.Client&version=1.9.0
Logging.Client
Shared structured logging configuration with Serilog, Grafana Loki sink, PII masking, correlation ID tracking, and tenant-aware enrichers for all SaaS services.
Installation
dotnet add package Logging.Client
Description
Shared structured logging configuration with Serilog, Grafana Loki sink, PII masking, correlation ID tracking, and tenant-aware enrichers for all SaaS services.
Sink selection (read this before setting SinkType)
The console sink is the default and the recommended sink everywhere. Promtail runs on
both clusters and already ships container stdout to the real Loki (prod promtail →
http://10.0.0.2:31300/loki/api/v1/push, label cluster: prod), so the direct Serilog Loki
sink is redundant — it only adds a failure mode.
That failure mode is a memory leak, not an outage. The Grafana Loki sink buffers every event
it cannot deliver. Pointed at a host that does not resolve, delivery can never succeed, so the
buffer only grows until the pod is OOMKilled. LokiQueueLimit bounds how big that buffer gets;
it does not notice that the sink is dead.
Since 1.6.0 the package therefore:
- defaults
SinkTypetoConsole; - runs a startup guard when
SinkType = Loki— it resolves the configured Loki host in DNS (2 s hard bound, never throws, never blocks boot) and, if the host does not resolve or the URL is malformed, prints a loud*** LOKI SINK DISABLED ***banner to stderr and falls back to the console sink; - binds
Logging:SinkTypeandLogging:LokiUrlfrom configuration, so the opt-in below actually reaches the options.
# opt back into the direct sink (both required — the URL default is NXDOMAIN in prod)
Logging__SinkType=Loki
Logging__LokiUrl=http://loki.monitoring.svc.cluster.local:3100
Configuration wins over the values passed to AddStructuredLogging(opts => ...).
Running without Loki or Sentry (since 1.7.0)
| Setting | Effect |
|---|---|
Logging__SinkType=Console (default) |
stdout only; needs no Loki |
Logging__SinkType=None |
no sink at all, not even the console |
Sentry__Enabled=false |
Sentry stays off even if Sentry__Dsn is set |
Correlation-id enrichment, the X-Correlation-ID middleware and the PII masking policy stay in
the pipeline in every mode; nothing contacts Loki or Sentry unless selected.
Documentation
See the NuGet package page for full documentation.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
How to Publish
The API key is read automatically from SaaS/.env.local (NUGET_API_KEY) — never pass or
paste -ApiKey.
cd C:\desktopContents\projects\SaaS\NuGetPackages\Logging.Client
.\publish.ps1 -Bump patch # Bug fixes
.\publish.ps1 -Bump minor # New features
.\publish.ps1 -Bump major # Breaking changes
.\publish.ps1 -NoBump # Publish the version already in Directory.Build.props
| Product | Versions 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. |
-
net10.0
- Sentry.AspNetCore (>= 6.12.1)
- Sentry.Serilog (>= 6.12.1)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Sinks.Grafana.Loki (>= 8.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Logging.Client:
| Package | Downloads |
|---|---|
|
Bff.AspNetCore
Reusable Backend-For-Frontend engine for ASP.NET Core. Terminates auth server-side: holds OIDC tokens in a Redis-backed session, hands the browser only an opaque httpOnly cookie, and forwards Bearer tokens to downstream services via YARP. Provider-agnostic — targets Keycloak (default, realm-scoped) or a generic OpenIddict provider (/connect/*), selectable per app. Server-side ROPC (Keycloak) or authorization-code + PKCE, silent refresh with a per-session SETNX lock, and CSRF protection. A per-app BFF becomes a ~20-line Program.cs. |
GitHub repositories
This package is not used by any popular GitHub repositories.