Skip to content

Add HTTPClientHandler to BetterstackHttpClient#10

Merged
PetrHeinz merged 3 commits intoBetterStackHQ:mainfrom
pedrobarrios-png:BetterStackHttpClient-AddHandler
Nov 4, 2025
Merged

Add HTTPClientHandler to BetterstackHttpClient#10
PetrHeinz merged 3 commits intoBetterStackHQ:mainfrom
pedrobarrios-png:BetterStackHttpClient-AddHandler

Conversation

@pedrobarrios-png
Copy link
Copy Markdown
Contributor

This PR introduces an optional HttpClientHandler into the BetterStack HTTP client and exposes it through the LoggerSinkConfigurationExtensions BetterStack sink configuration.
Mainly to allow callers to supply a custom HttpClientHandler (for proxy settings, client certificates, custom SocketsHttpHandler options, etc).

BetterStackHttpClient.cs

  • Added an optional constructor parameter: HttpClientHandler? httpClientHandler = null
  • If a handler is provided, the internal HttpClient is constructed with it new HttpClient(httpClientHandler); otherwise a default HttpClient() is used.

LoggerSinkConfigurationExtensions.cs

  • Added an optional parameter to the BetterStack sink extension: HttpClientHandler? httpClientHandler = null

Usage example
Passing a custom handler to the sink:
var handler = new HttpClientHandler { Proxy, UseProxy, ClientCertificates, etc };
Log.Logger = new LoggerConfiguration().WriteTo.BetterStack(sourceToken, httpClientHandler: handler).CreateLogger();

@pedrobarrios-png pedrobarrios-png changed the title Better stack http client add handler Add HTTPClientHandler to BetterstackHttpClient Nov 3, 2025
@PetrHeinz
Copy link
Copy Markdown
Member

Thanks @pedrobarrios-png for your contribution 🙌

The updated version works nicely, and provides nice additional options of configurations with full backward compatibility 🚀

I'll make sure to release as v1.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants