IHttpClientLogger Interface

Definition

An abstraction for custom HTTP request logging for named HttpClient instances returned by IHttpClientFactory.

public interface class IHttpClientLogger
public interface IHttpClientLogger
type IHttpClientLogger = interface
Public Interface IHttpClientLogger
Derived

Remarks

It is up to the user implementing the interface to decide where (to ILogger, or anything else) and what exactly to log. However, the implementation should be mindful about potential adverse side effects of accessing some of the HttpRequestMessage or HttpResponseMessage properties, such as reading from a content stream. If possible, such behavior should be avoided.

The logging implementation shouldn't throw any exceptions, as an unhandled exception in logging would fail the request.

Methods

LogRequestFailed(Object, HttpRequestMessage, HttpResponseMessage, Exception, TimeSpan)

Logs the exception that occurred while sending an HTTP request.

LogRequestStart(HttpRequestMessage)

Logs before sending an HTTP request.

LogRequestStop(Object, HttpRequestMessage, HttpResponseMessage, TimeSpan)

Logs after receiving an HTTP response.

Applies to