NLog.Targets.OpenTelemetryHttp 6.0.5-Preview2

This is a prerelease version of NLog.Targets.OpenTelemetryHttp.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package NLog.Targets.OpenTelemetryHttp --version 6.0.5-Preview2
                    
NuGet\Install-Package NLog.Targets.OpenTelemetryHttp -Version 6.0.5-Preview2
                    
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.OpenTelemetryHttp" Version="6.0.5-Preview2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NLog.Targets.OpenTelemetryHttp" Version="6.0.5-Preview2" />
                    
Directory.Packages.props
<PackageReference Include="NLog.Targets.OpenTelemetryHttp" />
                    
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.OpenTelemetryHttp --version 6.0.5-Preview2
                    
#r "nuget: NLog.Targets.OpenTelemetryHttp, 6.0.5-Preview2"
                    
#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.OpenTelemetryHttp@6.0.5-Preview2
                    
#: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.OpenTelemetryHttp&version=6.0.5-Preview2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NLog.Targets.OpenTelemetryHttp&version=6.0.5-Preview2&prerelease
                    
Install as a Cake Tool

NLog.Targets.OpenTelemetryHttp

Version AppVeyor

NLog OpenTelemetry target for sending log messages to an OpenTelemetry OTLP endpoint using protobuf encoding over HTTP (OTLP/HTTP).

If having trouble with output, then check NLog InternalLogger for clues. See also Troubleshooting NLog.

See also:

Register Extension

NLog will only recognize the type-alias OpenTelemetry when loading from an NLog.config file after registering the extension:

<extensions>
    <add assembly="NLog.Targets.OpenTelemetryHttp"/>
</extensions>

Alternative - register from code using the fluent configuration API:

LogManager.Setup().SetupExtensions(ext => {
    ext.RegisterTarget<NLog.Targets.OpenTelemetryHttpTarget>();
});

Configuration Example

Typical endpoint URL is http://localhost:4318/v1/logs.

Supports standard OpenTelemetry environment variables as fallback defaults: OTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_LOGS_ENDPOINT, OTEL_EXPORTER_OTLP_HEADERS, OTEL_EXPORTER_OTLP_LOGS_HEADERS, OTEL_EXPORTER_OTLP_COMPRESSION, OTEL_EXPORTER_OTLP_LOGS_COMPRESSION, OTEL_EXPORTER_OTLP_TIMEOUT, OTEL_EXPORTER_OTLP_LOGS_TIMEOUT, OTEL_SERVICE_NAME, OTEL_RESOURCE_ATTRIBUTES.

<targets>
    <target xsi:type="OpenTelemetry"
            name="otel"
            url="http://localhost:4318/v1/logs"
            serviceName="MyApplication"
            layout="${message}" />
</targets>

<rules>
    <logger name="*" minlevel="Info" writeTo="otel" />
</rules>

Parameters

Parameters

Parameter Default Description
url OTEL_EXPORTER_OTLP_ENDPOINT OTLP/HTTP endpoint URL. Automatically append /v1/logs when missing
serviceName ${appdomain:format=Friendly} OpenTelemetry service.name resource attribute.
serviceVersion ${assembly-version:Default=} OpenTelemetry service.version resource attribute.
hostName ${hostname} OpenTelemetry host.name resource attribute.
scopeName NLog OpenTelemetry instrumentation scope name.
layout ${message} Layout used for the OTLP log body (message text).
traceId ${activity:property=TraceId} Layout used to populate the OTLP LogRecord TraceId field.
spanId ${activity:property=SpanId} Layout used to populate the OTLP LogRecord SpanId field.
compress None Optional payload compression. Supports None, GZip, and GZipFast.
batchSize 200 Maximum number of log events processed in a batch before transmission.
includeEventProperties true Includes NLog event properties as OpenTelemetry log attributes.
sendTimeoutSeconds 30 HTTP request timeout.
maxPayloadSizeBytes 40960 Maximum payload size before automatic request chunking occurs.
sslCertificateFile Client certificate file used for mutual TLS authentication.
sslCertificatePassword Password for the client certificate.
proxyUrl Proxy server URL.
proxyUser Proxy authentication username.
proxyPassword Proxy authentication password.
batchSize 200 Maximum number of log events to send in a single HTTP payload.
taskDelayMilliseconds 50 Delay before processing queued log events. Higher value can improve batching
taskTimeoutSeconds 150 Maximum execution time in seconds before cancellation of HTTP request.
retryCount 3 Number of retry attempts for failed write operations.
retryDelayMilliseconds 2500 Initial delay before retry after failed request. Delay doubles for each retry.
queueLimit 10000 Maximum number of pending requests allowed in the internal queue.
overflowAction Discard Action taken when the internal request queue reaches its limit.

Resource Attributes

Additional OpenTelemetry resource attributes can be configured using resourceAttribute entries:

<target xsi:type="OpenTelemetry" name="otel">

    <resourceAttribute name="service.namespace" layout="Backend" />
    <resourceAttribute name="deployment.environment" layout="Production" />

</target>

These attributes are attached to every exported log record.

OpenTelemetry Environment Variables

The target automatically resolves standard OpenTelemetry environment variables when equivalent target properties have not been explicitly configured.

Endpoint

Order of precedence:

  1. OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
  2. OTEL_EXPORTER_OTLP_ENDPOINT

When OTEL_EXPORTER_OTLP_ENDPOINT is used, /v1/logs is automatically appended.

Headers

Order of precedence:

  1. OTEL_EXPORTER_OTLP_LOGS_HEADERS
  2. OTEL_EXPORTER_OTLP_HEADERS

Example:

OTEL_EXPORTER_OTLP_HEADERS=api-key=my-secret-key

Compression

Order of precedence:

  1. OTEL_EXPORTER_OTLP_LOGS_COMPRESSION
  2. OTEL_EXPORTER_OTLP_COMPRESSION

Supported values:

  • gzip
  • none

Timeout

Order of precedence:

  1. OTEL_EXPORTER_OTLP_LOGS_TIMEOUT
  2. OTEL_EXPORTER_OTLP_TIMEOUT

Timeout values are specified in milliseconds.

Service Name

OTEL_SERVICE_NAME

Overrides the service.name value from OTEL_RESOURCE_ATTRIBUTES.

Resource Attributes

OTEL_RESOURCE_ATTRIBUTES

Example:

OTEL_RESOURCE_ATTRIBUTES=service.namespace=Backend,deployment.environment=Production

The special attribute:

service.name

is automatically mapped to the serviceName property.

Client Certificate

Order of precedence:

  1. OTEL_EXPORTER_OTLP_LOGS_CLIENT_CERTIFICATE
  2. OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE

Used to configure mutual TLS authentication.

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 is compatible.  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 is compatible.  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 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 is compatible.  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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.1.4-Preview4 31 7/13/2026
6.1.4-Preview3 41 7/9/2026
6.0.5-Preview2 51 6/22/2026
6.0.5-Preview1 39 6/20/2026

Changelog:

- Preview2 Release of OpenTelemetryHttpTarget.