Skip to content

Conversation

@iliar-turdushev
Copy link
Contributor

@iliar-turdushev iliar-turdushev commented Aug 4, 2025

Adds the {OriginalFormat} property to the list of tags of HttpClient logs.

Fixes #6364

Microsoft Reviewers: Open in CodeFlow

Adds the {OriginalFormat} property to the list of tags of HttpClient logs
Copilot AI review requested due to automatic review settings August 4, 2025 15:54
@iliar-turdushev iliar-turdushev requested a review from a team as a code owner August 4, 2025 15:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds the {OriginalFormat} property to HttpClient logging to support structured logging scenarios. The change ensures that all HttpClient logs include the original format template as their last tag property.

  • Updates the log message state construction to include the {OriginalFormat} tag
  • Increases the minimal property count from 4 to 5 to accommodate the new tag
  • Adds comprehensive test coverage to verify the presence of {OriginalFormat} in all logging scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/Internal/Log.cs Adds {OriginalFormat} tag to all HttpClient log entries and updates property count
test/Libraries/Microsoft.Extensions.Http.Diagnostics.Tests/Logging/HttpClientLoggerTest.cs Adds test verification for {OriginalFormat} presence in all test scenarios
test/Libraries/Microsoft.Extensions.Http.Diagnostics.Tests/Logging/AcceptanceTests.cs Updates expected tag counts to account for the new {OriginalFormat} property
Comments suppressed due to low confidence (1)

test/Libraries/Microsoft.Extensions.Http.Diagnostics.Tests/Logging/HttpClientLoggerTest.cs:1040

  • The hardcoded expected value in the test doesn't match the actual OriginalFormatValue constant used in the production code. The production code uses HttpClientLoggingTagNames.Method, HttpClientLoggingTagNames.Host, and HttpClientLoggingTagNames.Path which may have different values than the hardcoded string in the test.
        Assert.Equal("{http.request.method} {server.address}/{url.path}", pair.Value);

@iliar-turdushev iliar-turdushev merged commit 2fbb776 into dotnet:main Aug 5, 2025
7 checks passed
@iliar-turdushev iliar-turdushev deleted the httplogging-msgformat branch August 5, 2025 13:07
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extended HttpClient logger doesn't export {OriginalFormat} field

4 participants