NLog.Targets.OpenTelemetryProtocol
1.0.6
See the version list below for details.
dotnet add package NLog.Targets.OpenTelemetryProtocol --version 1.0.6
NuGet\Install-Package NLog.Targets.OpenTelemetryProtocol -Version 1.0.6
<PackageReference Include="NLog.Targets.OpenTelemetryProtocol" Version="1.0.6" />
<PackageVersion Include="NLog.Targets.OpenTelemetryProtocol" Version="1.0.6" />
<PackageReference Include="NLog.Targets.OpenTelemetryProtocol" />
paket add NLog.Targets.OpenTelemetryProtocol --version 1.0.6
#r "nuget: NLog.Targets.OpenTelemetryProtocol, 1.0.6"
#:package NLog.Targets.OpenTelemetryProtocol@1.0.6
#addin nuget:?package=NLog.Targets.OpenTelemetryProtocol&version=1.0.6
#tool nuget:?package=NLog.Targets.OpenTelemetryProtocol&version=1.0.6
NLog Target for OpenTelemetry
This target can export logs in the format defined in the OpenTelemetry specification using the OpenTelemetry.Exporter.OpenTelemetryProtocol package.
The package also includes a lightweight version of the target called OtlpTargetLightweight
, which is missing some features (GlobalDiagnosticsContext
,
MappedDiagnosticsContext
, MappedDiagnosticsLogicalContext
),
but is about twice as fast and allocates about half as much memory. Configs for the 2 targets are compatible.
For an explanation of the log data model, see https://opentelemetry.io/docs/specs/otel/logs/data-model/. <br> For an example, see https://opentelemetry.io/docs/specs/otel/protocol/file-exporter/#examples.
Note that the OpenTelemetry logging API is still unfinished.
Configuration
Example XML config:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<extensions>
<add assembly="NLog.Targets.OpenTelemetryProtocol"/>
</extensions>
<targets>
<target xsi:type="OtlpTarget"
name="otlp"
usehttp="true"
servicename="TestService"
scheduledDelayMilliseconds="1000"
useDefaultResources="false"
includeFormattedMessage="false">
<attribute name="thread.id" layout="${threadid}" />
<resource name="process.name" layout="${processname}" />
<resource name="process.id" layout="${processid}" />
<resource name="deployment.environment" layout="DEV" />
</target>
<target xsi:type="OtlpTargetLightweight"
name="lightweight"
usehttp="true"
servicename="TestService"
scheduledDelayMilliseconds="1000"
useDefaultResources="false"
includeFormattedMessage="false">
<attribute name="thread.id" layout="${threadid}" />
<resource name="process.name" layout="${processname}" />
<resource name="process.id" layout="${processid}" />
<resource name="deployment.environment" layout="DEV" />
</target>
</targets>
<rules>
<logger name="*" writeTo="otlp" />
<logger name="*" writeTo="lightweight" />
</rules>
</nlog>
Configuration parameters
- UseHttp : Determines whether logs are exported using gRPC or HTTP. Optional, by default false, meaning the gRPC exporter will be used.
- Endpoint : Determines where the exporter should send logs. Used to set OtlpExporterOptions.Endpoint. If left empty, the default values will be used (optional)
- Headers : Used to set OtlpExporterOptions.Headers (optional)
- ServiceName : Used to set the service.name resource (optional)
- Resource : Additional resources to include in the ResourceBuilder (optional)
- Name : Name of Resource.
- Layout : Value of Resource (Will only resolve value at target initialize)
- Attribute : Attributes to be included with each LogEvent (optional)
- Name : Name of Attribute.
- Layout : Value of Attribute (If value is the same for all LogEvents, then add as resource instead)
- MaxQueueSize : The target uses a batch exporter, this defines the max queue size. By default 2048, optional.
- MaxExportBatchSize : The target uses a batch exporter, this defines the max batch size. By default 512, optional.
- ScheduledDelayMilliseconds : The target uses a batch exporter, this defines how often it is flushed in milliseconds. By default 5000, optional.
- UseDefaultResources : By default each exported batch will contain the resources telemetry.sdk.name, telemetry.sdk.language and telemetry.sdk.version. If you don't want them, set to false.
- IncludeFormattedMessage : If you're doing structured logging, this determines whether the body of the outputted log should be the formatted message or the message template. By default false, meaning the body of the outputted log will be the message template. If you aren't doing structured logging, leave this as false.
- IncludeEventProperties : If you're doing structured logging, this determines whether to include NLog LogEvent properties as attributes. By default true, optional.
- IncludeScopeProperties : If you're doing structured logging, this determines whether to include NLog ScopeContext properties as attributes. By default false, optional.
- IncludeEventParameters : Whether to fallback to including NLog LogEvent parameters as attributes, when no NLog LogEvent properties. By default false, optional.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- NLog (>= 5.0.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.7.0-rc.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on NLog.Targets.OpenTelemetryProtocol:
Repository | Stars |
---|---|
tonyalaribe/todoapi
.NET otel logger example
|
Version | Downloads | Last Updated |
---|---|---|
1.2.2 | 5,855 | 6/26/2025 |
1.2.1 | 4,670 | 6/8/2025 |
1.1.10 | 4,843 | 4/28/2025 |
1.1.9 | 3,850 | 3/21/2025 |
1.1.8 | 1,270 | 3/14/2025 |
1.1.7 | 8,133 | 1/8/2025 |
1.1.6 | 15,032 | 11/19/2024 |
1.1.5 | 974 | 10/17/2024 |
1.1.4 | 20,809 | 6/5/2024 |
1.1.3 | 448 | 5/20/2024 |
1.1.2 | 104 | 5/16/2024 |
1.1.1 | 158 | 3/19/2024 |
1.1.0 | 5,533 | 3/15/2024 |
1.0.8 | 150 | 2/27/2024 |
1.0.7 | 109 | 2/22/2024 |
1.0.6 | 107 | 2/19/2024 |
1.0.5 | 1,524 | 2/8/2024 |
1.0.4 | 119 | 2/7/2024 |
1.0.3 | 98 | 2/5/2024 |
1.0.2 | 153 | 2/1/2024 |
1.0.1 | 525 | 1/29/2024 |
1.0.0 | 381 | 1/29/2024 |