NLog.Targets.HttpClient
6.0.5-Preview2
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
<PackageReference Include="NLog.Targets.HttpClient" Version="6.0.5-Preview2" />
<PackageVersion Include="NLog.Targets.HttpClient" Version="6.0.5-Preview2" />
<PackageReference Include="NLog.Targets.HttpClient" />
paket add NLog.Targets.HttpClient --version 6.0.5-Preview2
#r "nuget: NLog.Targets.HttpClient, 6.0.5-Preview2"
#:package NLog.Targets.HttpClient@6.0.5-Preview2
#addin nuget:?package=NLog.Targets.HttpClient&version=6.0.5-Preview2&prerelease
#tool nuget:?package=NLog.Targets.HttpClient&version=6.0.5-Preview2&prerelease
NLog.Targets.HttpClient
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 | 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 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. |
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.