/// <summary>
        /// Traces the full <paramref name="request"/> when the interaction is on error.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger"/>.</param>
        /// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
        /// <param name="ex">The <see cref="Exception"/> if any.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public static async Task RequestError(this ILogger logger, HttpRequestMessage request, Exception ex = null)
        {
            if (request == null)
            {
                return;
            }

            _requestError(
                logger,
                request.Method,
                request.RequestUri,
                $"HTTP/{request.Version}",
                request.AllHeadersAsString(),
                await SafeContentAsString(request.Content).ConfigureAwait(false),
                ex);
        }
コード例 #2
0
        /// <summary>
        /// Traces the full <paramref name="request"/> when the interaction is on error.
        /// </summary>
        /// <param name="logger">The <see cref="ILogger"/>.</param>
        /// <param name="request">The <see cref="HttpRequestMessage"/>.</param>
        /// <param name="ex">The <see cref="Exception"/> if any.</param>
        /// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
        public static async Task RequestError(this ILogger logger, HttpRequestMessage request, Exception ex = null)
        {
            if (request == null)
            {
                return;
            }

            _requestError(
                logger,
                request.Method,
                request.RequestUri,
                $"HTTP/{request.Version}",
                request.AllHeadersAsString(),
                request.Content == null ? string.Empty : await request.Content.ReadAsStringAsync(),
                ex);
        }