Ejemplo n.º 1
0
        public static void LogResponseHeaders(HttpResponse response, HttpLoggingOptions options, ILogger logger)
        {
            var list = new List <KeyValuePair <string, object?> >(
                response.Headers.Count + DefaultResponseFieldsMinusHeaders);

            if (options.LoggingFields.HasFlag(HttpLoggingFields.ResponseStatusCode))
            {
                list.Add(new KeyValuePair <string, object?>(nameof(response.StatusCode), response.StatusCode));
            }

            if (options.LoggingFields.HasFlag(HttpLoggingFields.ResponseHeaders))
            {
                FilterHeaders(list, response.Headers, options._internalResponseHeaders);
            }

            var httpResponseLog = new HttpResponseLog(list);

            logger.ResponseLog(httpResponseLog);
        }
Ejemplo n.º 2
0
 public static void ResponseLog(this ILogger logger, HttpResponseLog responseLog) => logger.Log(
     LogLevel.Information,
     new EventId(2, "ResponseLog"),
     responseLog,
     exception: null,
     formatter: HttpResponseLog.Callback);