Skip to content

HttpClientTarget - HttpClient with support for batching#20

Open
snakefoot wants to merge 19 commits intoNLog:masterfrom
snakefoot:httpclient
Open

HttpClientTarget - HttpClient with support for batching#20
snakefoot wants to merge 19 commits intoNLog:masterfrom
snakefoot:httpclient

Conversation

@snakefoot
Copy link
Copy Markdown
Contributor

@snakefoot snakefoot commented Mar 15, 2026

I guess for OpenTelemetry with GRPC-protocol, then this must be opened up a little more to serialize with protobuf.

But right now it support Json / Xml that is encoded as UTF8 along with optional GZip compression.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new HttpClientTarget to NLog.Targets.Network (for non-NET35 TFMs) and introduces an accompanying test suite that validates HTTP method selection, batching behavior, headers, gzip compression, payload splitting, and retry behavior.

Changes:

  • Added HttpClientTarget implementation with batching, optional gzip compression, custom headers, proxy support, and retry handling.
  • Added HttpClientTargetTests with a lightweight in-process TCP HTTP server to validate outgoing requests.
  • Updated NLog.Targets.Network.csproj target frameworks (adds net471) and framework references to support HttpClient.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.

File Description
tests/NLog.Targets.Network.Tests/HttpClientTargetTests.cs New tests validating HTTP request behavior for the new target.
src/NLog.Targets.Network/Targets/HttpClientTarget.cs New HttpClientTarget implementation (batching, compression, headers, proxy, retry).
src/NLog.Targets.Network/NLog.Targets.Network.csproj Adds net471 target and System.Net.Http reference for .NET Framework builds (non-net35).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/NLog.Targets.HttpClient/HttpClientTarget.cs
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.HttpClient/HttpClientTarget.cs
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
@snakefoot snakefoot force-pushed the httpclient branch 9 times, most recently from 74664c2 to 7d92a44 Compare March 15, 2026 16:42
@snakefoot snakefoot requested a review from Copilot March 15, 2026 16:42
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces a new HttpClientTarget to the NLog.Targets.Network package for sending log events over HTTP(S), along with a new test suite and updated multi-targeting/package settings to support additional .NET Framework versions.

Changes:

  • Add HttpClientTarget implementation (HTTP method selection, headers, proxy, retries, batching, compression, max payload splitting).
  • Add HttpClientTargetTests using a minimal in-process TCP HTTP server to validate behavior.
  • Expand target frameworks to include net471 and update test SDK package version.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
tests/NLog.Targets.Network.Tests/NLog.Targets.Network.Tests.csproj Adds net471 to test TFMs and updates Microsoft.NET.Test.Sdk.
tests/NLog.Targets.Network.Tests/HttpClientTargetTests.cs New tests covering basic send, headers, batching, gzip, and retry behavior.
src/NLog.Targets.Network/Targets/HttpClientTarget.cs New HttpClient-based target implementation.
src/NLog.Targets.Network/NLog.Targets.Network.csproj Adds net471 and conditional framework references required for HttpClient.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread tests/NLog.Targets.HttpClient.Tests/HttpClientTargetTests.cs
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.HttpClient/HttpClientTarget.cs
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.HttpClient/HttpClientTarget.cs
@snakefoot snakefoot force-pushed the httpclient branch 4 times, most recently from 662ff23 to edcd065 Compare April 26, 2026 06:09
@snakefoot snakefoot requested a review from Copilot April 26, 2026 06:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/NLog.Targets.HttpClient/HttpClientTarget.cs
Comment thread src/NLog.Targets.HttpClient/HttpClientTarget.cs
Comment thread src/NLog.Targets.Network/Targets/HttpClientTarget.cs Outdated
Comment thread src/NLog.Targets.HttpClient/HttpClientTarget.cs
Comment thread src/NLog.Targets.Network/Targets/NetworkTarget.cs
Comment thread src/NLog.Targets.Network/NLog.Targets.Network.csproj Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants