.NET bindings for Polyglot — a shared Go logging core with a C ABI. Same polyglot.yaml, JSON shape, and sinks as the Node and Python packages. Native libs ship in the NuGet package (Linux, Windows, macOS arm64); no Go/CGO required.
Current line: 0.3.x.
dotnet add package Polyglot.Loggerusing Polyglot.Logger;
using var log = new Logger(new LoggerOptions { Service = "api", Stdout = true });
log.Info("hello", new Dictionary<string, object?> { ["user_id"] = 1 });Prefer using so dispose always runs and sinks shut down cleanly. Side-by-side APIs: sdk.md.
Constructors load polyglot.yaml via POLYGLOT_CONFIG → cwd → parents (stop at .git). Options override file keys.
# polyglot.yaml (repo root)
service: billing-api
environment: prod
level: info
stdout: true
file:
enabled: true
path: app.logusing var log = new Logger(new LoggerOptions { Service = "billing-api" });Full schema: configuration · zero-config.
using Polyglot.Logger;
using var log = new Logger(new LoggerOptions
{
Service = "billing-api",
Environment = "prod",
Level = "info",
Stdout = true,
});
log.SetFields(new Dictionary<string, object?> { ["region"] = "us-east" });
using var req = log.With(new Dictionary<string, object?> { ["request_id"] = "r1" });
req.Info("invoice issued", new Dictionary<string, object?> { ["invoice_id"] = 99 });
req.LogSimple(Level.Error, "billing failed");
log.Flush();- Levels:
Trace…Fatal(Fataldoes not callEnvironment.Exit). - Prefer
With(...)(orRequestLogging.ForRequest) for per-request context; avoid sharingSetFieldsacross concurrent requests. - One instance is fine for concurrent
Info/Flush/Stats/SetFields. Dispose the root logger to shut down sinks; disposing a child only frees the child handle. - On Windows, dispose before reading the active log file from the same process.
Published packages include platform natives under native/ / bin/ (and NuGet runtimes/). For a local monorepo build:
export POLYGLOT_LOGGER_LIB=$PWD/dist/logger.dll # liblogger.so / liblogger.dylibIntel Macs: arm64 is what ships today; set POLYGLOT_LOGGER_LIB for amd64 until CI covers it.
git clone --recurse-submodules https://github.com/kishankumarhs/Polyglot.git
cd Polyglot && make build-native
dotnet build bindings/dotnet/Polyglot.Logger/Polyglot.Logger.csproj- First log
- .NET API
- Configuration
- Sinks & Loki
- Migrate from Serilog
- Compatibility
- Benchmarks / methodology
Polyglot is for multi-language stacks that want one ops model — shared config and sinks without reimplementing them per language.
Repos: polyglot-csharp · core: Polyglot
MIT