NLog.Targets.OpenTelemetryProtocol 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NLog.Targets.OpenTelemetryProtocol --version 1.0.1
                    
NuGet\Install-Package NLog.Targets.OpenTelemetryProtocol -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NLog.Targets.OpenTelemetryProtocol" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NLog.Targets.OpenTelemetryProtocol" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="NLog.Targets.OpenTelemetryProtocol" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NLog.Targets.OpenTelemetryProtocol --version 1.0.1
                    
#r "nuget: NLog.Targets.OpenTelemetryProtocol, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package NLog.Targets.OpenTelemetryProtocol@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NLog.Targets.OpenTelemetryProtocol&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=NLog.Targets.OpenTelemetryProtocol&version=1.0.1
                    
Install as a Cake Tool

This target can export logs in the format defined in the OpenTelemetry specification using the OpenTelemetry.Exporter.OpenTelemetryProtocol package.

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"
        resources="process.name=${processname};process.id=${processid};deployment.environment=DEV"
        attributes="thread.id=${thread.id}"
        servicename="TestService"
        scheduledDelayMilliseconds="1000"
        useDefaultResource="false"
        includeFormattedMessage="true"/>
    </targets>
    <rules>
        
        <logger name="*" writeTo="otlp" />
    </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)
  • Resources : Used to set resources in the ResourceBuilder. It must be in the format like in the example above (optional)
  • ServiceName : Used to set the service.name resource (optional)
  • Attributes : Attributes which each log should contain. It must be in the same format as resources. Attributes are rendered everytime a log is written, so if an attribute would have the same value in all logs, set it in resources instead.
  • 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.
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 4,335 6/26/2025
1.2.1 4,537 6/8/2025
1.1.10 4,676 4/28/2025
1.1.9 3,843 3/21/2025
1.1.8 1,268 3/14/2025
1.1.7 8,070 1/8/2025
1.1.6 14,968 11/19/2024
1.1.5 973 10/17/2024
1.1.4 20,743 6/5/2024
1.1.3 431 5/20/2024
1.1.2 103 5/16/2024
1.1.1 158 3/19/2024
1.1.0 5,457 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 97 2/5/2024
1.0.2 152 2/1/2024
1.0.1 525 1/29/2024
1.0.0 360 1/29/2024