NLog.Targets.HttpClient 6.0.5-Preview2

This is a prerelease version of NLog.Targets.HttpClient.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package NLog.Targets.HttpClient --version 6.0.5-Preview2
                    
NuGet\Install-Package NLog.Targets.HttpClient -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.HttpClient" 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.HttpClient" Version="6.0.5-Preview2" />
                    
Directory.Packages.props
<PackageReference Include="NLog.Targets.HttpClient" />
                    
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.HttpClient --version 6.0.5-Preview2
                    
#r "nuget: NLog.Targets.HttpClient, 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.HttpClient@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.HttpClient&version=6.0.5-Preview2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=NLog.Targets.HttpClient&version=6.0.5-Preview2&prerelease
                    
Install as a Cake Tool

NLog.Targets.HttpClient

Version AppVeyor

NLog HttpClient target for sending log events to an HTTP or HTTPS endpoint.

  • HTTP POST, GET, and custom HTTP methods
  • Batching of multiple log events
  • JSON array batching
  • GZip compression
  • Custom request headers
  • HTTP authentication
  • Client certificates (mTLS)
  • Proxy servers

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

Register Extension

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

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

Alternative - register from code using the fluent configuration API:

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

Configuration Example

<targets>
    <target xsi:type="HttpClient"
            name="http"
            url="https://api.example.com/logs"
            layout="${json-encode:${message}}" />
</targets>

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

Parameters

Parameters

Parameter Default Description
url Required Destination URL for HTTP requests.
httpMethod POST HTTP method used when sending requests.
contentType application/json Value of the HTTP Content-Type header.
keepAlive true Reuses TCP connections between requests.
expect100Continue false Controls HTTP 100-Continue behavior.
lineEnding LF Line separator used when batching log events.
batchAsJsonArray false Wraps batched log events in a JSON array. Disables lineEnding value
sendTimeoutSeconds 30 HTTP request timeout in seconds.
networkUserName Username for HTTP authentication. networkUserName = "" means default NTLM credentials.
networkPassword Password for HTTP authentication.
sslCertificateFile Client certificate file used for mutual TLS authentication.
sslCertificatePassword Password for the client certificate.
maxPayloadSizeBytes 40960 Max payload size before splitting into multiple HTTP requests. Remember BatchSize
compress None Payload compression mode (None, GZip, GZipFast).
proxyUrl Proxy server URL.
proxyUser Proxy authentication username.
proxyPassword Proxy authentication password.
headers Additional HTTP request headers.
batchSize 1 Maximum number of log events to send in a single HTTP payload.
taskDelayMilliseconds 1 Delay before processing queued log events. Higher value can improve batching
taskTimeoutSeconds 150 Maximum execution time in seconds before cancellation of HTTP request.
retryCount 0 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.

Custom Headers

Additional HTTP headers can be configured:

<target xsi:type="HttpClient"
        name="http"
        url="https://api.example.com/logs">

    <header name="X-Api-Key" layout="${gdc:item=ApiKey}" />
    <header name="X-Environment" layout="Production" />

</target>

Client Certificates (mTLS)

Mutual TLS authentication can be enabled using a client certificate:

<target xsi:type="HttpClient"
        name="http"
        url="https://secure.example.com/logs"
        sslCertificateFile="client.pfx"
        sslCertificatePassword="secret" />

Retry Behavior

The target treats the following status codes as transient failures, that can be retried:

  • 408 Request Timeout
  • 429 Too Many Requests
  • 5xx Server Errors

Client-side failures such as 400 Bad Request are not retried.

Notes

  • The target internally reuses HttpClient instance for connection pooling.
  • HttpClient instance is periodically recycled every 5 mins to handle DNS changes.
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 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.
  • .NETFramework 4.7.1

  • .NETStandard 2.0

  • .NETStandard 2.1

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NLog.Targets.HttpClient:

Package Downloads
NLog.Targets.OpenTelemetryHttp

NLog OpenTelemetryHttpTarget for sending log events to OpenTelemetry HTTP endpoint using protobuf (OTLP/HTTP).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
6.1.4-Preview4 34 7/13/2026
6.1.4-Preview3 89 7/9/2026
6.0.5-Preview2 292 6/22/2026
6.0.5-Preview1 42 6/20/2026

Changelog:

- Preview2 Release of HttpClientTarget.