IHttpClientAsyncLogger Interface

Definition

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

public interface class IHttpClientAsyncLogger : Microsoft::Extensions::Http::Logging::IHttpClientLogger
public interface IHttpClientAsyncLogger : Microsoft.Extensions.Http.Logging.IHttpClientLogger
type IHttpClientAsyncLogger = interface
    interface IHttpClientLogger
Public Interface IHttpClientAsyncLogger
Implements IHttpClientLogger
Implements

Remarks

Asynchronous methods (such as LogRequestStartAsync(HttpRequestMessage, CancellationToken)) are called from async code paths (such as SendAsync(HttpRequestMessage, CancellationToken)). Their synchronous counterparts inherited from IHttpClientLogger (such as LogRequestStart(HttpRequestMessage)) are called from the corresponding sync code paths.

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.

(Inherited from IHttpClientLogger)
LogRequestFailedAsync(Object, HttpRequestMessage, HttpResponseMessage, Exception, TimeSpan, CancellationToken)

Logs the exception that occurred while sending an HTTP request.

LogRequestStart(HttpRequestMessage)

Logs before sending an HTTP request.

(Inherited from IHttpClientLogger)
LogRequestStartAsync(HttpRequestMessage, CancellationToken)

Logs before sending an HTTP request.

LogRequestStop(Object, HttpRequestMessage, HttpResponseMessage, TimeSpan)

Logs after receiving an HTTP response.

(Inherited from IHttpClientLogger)
LogRequestStopAsync(Object, HttpRequestMessage, HttpResponseMessage, TimeSpan, CancellationToken)

Logs after receiving an HTTP response.

Applies to