After using services.AddHttpLogging(), the ResponseBody cannot be passed to Serilog for file logging.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
I reviewed the source code and found that adding "ResponseBody" to the logContext's "Parameters" occurs after the interceptor's "OnResponseAsync" method is executed. I want to access the "ResponseBody" within this method and add it to the diagnostic context for logging with Serilog, but I have found that this is currently not achievable.

I expect to add the "ResponseBody" to the diagnostic context in the red box area in the diagram, so that it can be provided to Serilog for file logging, like in the line diagnosticContext.Set("RequestBody", requestBody);

The log template content for Serilog is like this:

### Expected Behavior
In the SampleHttpLoggingInterceptor's OnResponseAsync method, read the ResponseBody from the logContext's Parameters, and then add it to the diagnostic context using diagnosticContext.Set("RequestBody", requestBody); to provide it to Serilog for file logging.
### Steps To Reproduce
_No response_
### Exceptions (if any)
_No response_
### .NET Version
.net 8.0
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.