Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Emit {OriginalFormat} in HttpClient logger - #6682

#6682
Merged
iliar-turdushev merged 1 commit into
dotnet:maindotnet/extensions:mainfrom
iliar-turdushev:httplogging-msgformatiliar-turdushev/dotnet-extensions:httplogging-msgformatCopy head branch name to clipboard
Aug 5, 2025
Merged

Emit {OriginalFormat} in HttpClient logger #6682
iliar-turdushev merged 1 commit into
dotnet:maindotnet/extensions:mainfrom
iliar-turdushev:httplogging-msgformatiliar-turdushev/dotnet-extensions:httplogging-msgformatCopy head branch name to clipboard

Conversation

@iliar-turdushev

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

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.