Logging.Client
1.6.0
dotnet add package Logging.Client --version 1.6.0
NuGet\Install-Package Logging.Client -Version 1.6.0
<PackageReference Include="Logging.Client" Version="1.6.0" />
<PackageVersion Include="Logging.Client" Version="1.6.0" />
<PackageReference Include="Logging.Client" />
paket add Logging.Client --version 1.6.0
#r "nuget: Logging.Client, 1.6.0"
#:package Logging.Client@1.6.0
#addin nuget:?package=Logging.Client&version=1.6.0
#tool nuget:?package=Logging.Client&version=1.6.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 => ...).
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.8.0)
- Sentry.Serilog (>= 6.8.0)
- Serilog.AspNetCore (>= 9.0.0)
- Serilog.Enrichers.Environment (>= 3.0.1)
- Serilog.Sinks.Grafana.Loki (>= 8.3.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.