Dela via


IHttpClientAsyncLogger Interface

Definition

An abstraction for asyncronous custom HTTP request logging for a 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

Asyncronous methods (such as LogRequestStartAsync(HttpRequestMessage, CancellationToken)) would be called from async code paths (such as SendAsync(HttpRequestMessage, CancellationToken)), and their syncronous counterparts inherited from IHttpClientLogger (such as LogRequestStart(HttpRequestMessage)) would be 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.

Logging implementation also should not throw any exceptions, as an unhandled exception in logging would fail the request.

Methods

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

Logs the exception happened while sending an HTTP request.

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

Logs the exception happened 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