Intellivega.Loki 1.0.1
Intellivega.Loki
Reusable .NET 10 Serilog integration for Loki, with local startup and delivery diagnostics.
Install and configure
Add https://baget.intellivega.com/v3/index.json to your NuGet sources, then install
Intellivega.Loki. In an ASP.NET Core host:
using Intellivega.Loki;
using Serilog;
var builder = WebApplication.CreateBuilder(args);
builder.Host.UseIntellivegaLoki();
var app = builder.Build();
app.UseSerilogRequestLogging();
app.MapGet("/", () => "Hello");
app.Run();
The package registers console and Loki sinks. Remove those sinks from Serilog:WriteTo
to avoid duplicate logging; additional sinks, enrichers, and minimum levels can still be
configured through the normal Serilog section. Do not also call UseSerilog.
{
"Loki": {
"Uri": "http://coolify01.intellivega.com:3100",
"ApplicationName": "my-application",
"ServiceName": "web"
},
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": { "Microsoft": "Warning", "System": "Warning" }
}
}
}
ASP.NET Core environment variables override JSON settings:
| Variable | Purpose / default |
|---|---|
Loki__Uri |
Required Loki base URL, including any reverse-proxy path prefix |
Loki__ApplicationName |
Required application label |
Loki__ServiceName |
service label; default web |
Loki__Enabled |
Default true; false keeps console logging only |
Loki__DiagnosticsEnabled |
Default true; false suppresses local stderr delivery diagnostics |
Loki__RequestTimeoutSeconds |
Push timeout; default 10 seconds, range 1–300 |
Loki__Username, Loki__Password |
Optional basic authentication; use a secret store |
Loki__Tenant |
Optional Loki tenant (upstream sink requires alphanumeric IDs) |
Environment is an additional label taken from the host environment, preserving case.
Settings are read when the host is built; restart after changing them.
Diagnosing missing logs
Local stderr reports the endpoint and an exact Grafana label selector when the logger is configured, even if application log levels filter Information events. At host startup an Information marker is queued through the real sink. If that level is filtered, stderr says so. Only a real push response of HTTP 204 produces the first accepted-batch message. Failure responses, DNS/network/TLS failures and timeouts are reported locally; the first successful push after a failure reports recovery. Successful batches thereafter are quiet.
Diagnostics bypass Serilog to remain visible in container logs and avoid recursive failures.
They do not include credentials, exception messages, or response bodies. An accepted batch
confirms the ingestion endpoint acknowledged it; it does not verify Grafana's data source,
query, tenant, or selected time range. No separate readiness probe is used.
Set Loki:DiagnosticsEnabled to false for design-time hosts or tools that treat stderr as
fatal. This does not disable console or Loki logging.
Delivery uses the upstream sink's asynchronous batching/retry behavior, a 10,000-event memory queue and a request timeout. It is not durable: queued logs can be lost on process failure or queue overflow. A Loki outage does not prevent host startup. Invalid required configuration does fail at startup. Host disposal flushes and disposes the logger.
Build, test, and publish
dotnet build -c Release
dotnet test -c Release
dotnet pack src/Intellivega.Loki -c Release -o artifacts
read -rsp "BaGet API key: " BAGET_API_KEY; echo
dotnet nuget push artifacts/Intellivega.Loki.1.0.1.nupkg \
--source https://baget.intellivega.com/v3/index.json \
--api-key "$BAGET_API_KEY"
unset BAGET_API_KEY
Publishing is manual, matching the existing Intellivega packages. GitHub Actions builds,
tests, and uploads the NuGet package as a private workflow artifact; no publish key is stored
in this repository. Increment Version in the project before publishing a new release.
The HTTP diagnostics extend the pinned Serilog Loki sink 8.3.1.
No packages depend on Intellivega.Loki.
.NET 10.0
- Serilog.AspNetCore (>= 10.0.0)
- Serilog.Sinks.Console (>= 6.1.1)
- Serilog.Sinks.Grafana.Loki (>= 8.3.1)