- Auto-instrumentation — one-time installer script attaches the OTEL CLR profiler.
ILogger<T>statements are shipped automatically with no code changes. - SDK — add the
OpenTelemetry.*NuGet packages and wireAddOpenTelemetry().UseOtlpExporter()into your host. More control; requires touching startup code.
otel-logs-v0_9).
Setup
Structured logging
UseILogger<T>’s message-template form — .NET turns the named placeholders into structured attributes.
attributes.UserId and attributes.Plan in Logwiz and become searchable.
Framework recipe: ASP.NET Core
With the SDK path, add OTEL to the builder once — everyILogger<T> resolved from DI ships through OTLP automatically.
AddOpenTelemetry().UseOtlpExporter() call — the installer already wires the logger provider.
Troubleshooting
- 401 / 403 — the Bearer token is missing, malformed, or the
%20separator is not URL-encoded. Re-checkOTEL_EXPORTER_OTLP_LOGS_HEADERS. - Auto-instrumentation: no records — the
instrument.sh/instrument.ps1script must be sourced in the same shell that runsdotnet. If you run throughsystemdor similar, set theCORECLR_*env vars the script exports. - SDK: nothing visible —
AddOpenTelemetry().UseOtlpExporter()must be called beforeBuild(). Verify withbuilder.Services.BuildServiceProvider().GetRequiredService<ILoggerProvider>()returning an OTEL provider. - TLS errors against a self-signed endpoint — install the CA into the OS trust store, or set
SSL_CERT_FILE=/path/to/ca.pemon Linux.
