using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Compliance.Redaction;
using Microsoft.Extensions.Http.Diagnostics;
var builder = WebApplication.CreateBuilder(args);
builder.Logging.AddJsonConsole();
builder.Services.AddSingleton<IRedactorProvider, NullRedactorProvider>();
builder.Services.AddExtendedHttpClientLogging(options =>
{
#pragma warning disable EXTEXP0003
options.LogContentHeaders = true;
options.RequestBodyContentTypes.Add("application/json");
options.ResponseBodyContentTypes.Add("application/json");
options.LogBody = true;
options.RequestPathParameterRedactionMode = HttpRouteParameterRedactionMode.None;
});
var app = builder.Build();
app.MapGet("/", ([FromServices] HttpClient http) => http.GetStringAsync("https://jsonplaceholder.typicode.com/todos/1?query=value"));
app.Run();
{
"EventId": 1,
"LogLevel": "Information",
"Category": "Microsoft.Extensions.Http.Logging.HttpClientLogger",
"Message": "GET jsonplaceholder.typicode.com//todos/1",
"State": {
"Message": "http.request.method=GET,server.address=jsonplaceholder.typicode.com,url.path=/todos/1,Duration=886,http.response.status_code=200,RequestBody=,ResponseBody={\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}",
"http.request.method": "GET",
"server.address": "jsonplaceholder.typicode.com",
"url.path": "/todos/1",
"Duration": 886,
"http.response.status_code": 200,
"RequestBody": "",
"ResponseBody": "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
}
}
Description
It seems like the
AddExtendedHttpClientLoggingis able to log the http request and response bodies, headers and the path....but not query string parameters. this seems like an oversight....or am i missing something?Reproduction Steps
Expected behavior
the output to include the query string parameters
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response