Skip to content

Extended HTTP client logging doubles the slash between host and path when RequestPathParameterRedactionMode = None #7737

Closed

Description

@iikuzmychov

Description

When extended HTTP client logging is configured with RequestPathParameterRedactionMode = None, the formatted log message contains a doubled slash between the host and the path, e.g. GET github.com//dotnet/extensions.

The Strict and Loose redaction modes are not affected.

Reproduction Steps

DoubleSlashRepro.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.11" />
    <PackageReference Include="Microsoft.Extensions.Http.Diagnostics" Version="10.9.0" />
    <PackageReference Include="Microsoft.Extensions.Compliance.Redaction" Version="10.9.0" />
  </ItemGroup>

</Project>

Program.cs:

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Http.Diagnostics;

var builder = Host.CreateApplicationBuilder(args);

builder.Services.AddRedaction();

builder.Services.AddExtendedHttpClientLogging(o =>
{
    o.RequestPathParameterRedactionMode = HttpRouteParameterRedactionMode.None
});

builder.Services.AddHttpClient("probe");

using var host = builder.Build();

var client = host.Services.GetRequiredService<IHttpClientFactory>().CreateClient("probe");
await client.GetAsync("https://github.com/dotnet/extensions");

await Task.Delay(500);

Run dotnet run and observe the console output.

Expected behavior

info: Microsoft.Extensions.Http.Logging.HttpClientLogger[1]
      GET github.com/dotnet/extensions

Actual behavior

info: Microsoft.Extensions.Http.Logging.HttpClientLogger[1]
      GET github.com//dotnet/extensions

Only the rendered message is affected; the structured tags themselves are correct (server.address = github.com, url.path = /dotnet/extensions).

Regression?

No response

Known Workarounds

No response

Configuration

  • Microsoft.Extensions.Http.Diagnostics 10.9.0
  • Microsoft.Extensions.Compliance.Redaction 10.9.0
  • Microsoft.Extensions.Hosting 10.0.11
  • .NET SDK 10.0.302, Linux x64 (Ubuntu 24.04)
  • Not configuration-specific beyond RequestPathParameterRedactionMode = None

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-telemetrybugThis issue describes a behavior which is not expected - a bug.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions