-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more information and sample to Http.Diagnostics Readme #4808
Conversation
Thanks @joperezr for improving the docs! |
@@ -55,6 +55,47 @@ builder.Services.AddHttpClientLogEnricher<MyHttpClientLogEnricher>(); | |||
var host = builder.Build(); | |||
``` | |||
|
|||
It is important to note that the `AddExtendedHttpClientLogging` method will add information to the logs using *enrichment*. This means that the information will be added as tags to the structured logs, but will not be visible in the log message that is printed by default in the console. To view the information, you will need to use a logging provider that supports structured logs. One quick and built-in way to do this, is to call `AddJsonConsole()` to your logging builder, which will print out the full structured logs to the console. Here is a quick sample that uses the `ExtendedHttpClientLogging()` method to automatically log all `HttpClient` request and response bodies, and then prints the full structured logs to the console: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: the example below would only print the response body, because only ResponseBodyContentTypes
is set up, right? And the description says "request and response bodies"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! I'll fix that in a follow-up PR.
* Address issue with legacy logger's calling ToString on the TState arguments. (#4798) * Fix #4795 And while I was in the neighborhood, also addresses #4637 --------- Co-authored-by: Martin Taillefer <[email protected]> Co-authored-by: Igor Velikorossov <[email protected]> * Add missing [GeneratedCode] attribute (#4802) The logging code generator emits a static lambda. The lambda's containing function is annotated with the [GeneratedCode] attribute, but the lambda itself is not. The result is that code generators can get confused, considering the lambda as being user code. This PR adds the [GeneratedCode] attribute to the lambda. Co-authored-by: Martin Taillefer <[email protected]> * Add more information and sample to Http.Diagnostics Readme (#4808) * Add more information and sample to Http.Diagnostics Readme * Simplify first statement and adding using statements. * Also add extra docs to xml docs * Improve code coverage for M.E.Diagnostics.Testing (#4820) --------- Co-authored-by: Martin Taillefer <[email protected]> Co-authored-by: Martin Taillefer <[email protected]> Co-authored-by: Igor Velikorossov <[email protected]> Co-authored-by: Jose Perez Rodriguez <[email protected]> Co-authored-by: Sébastien Ros <[email protected]>
Adding more documentation to the Microsoft.Extensions.Http.Diagnostics package. We got a few reports stating that there is some confusion on how this package is intended to work, so hopefully this extra docs and samples will make it clearer and will help folks hitting issues with this.
cc: @CarnaViire @stephentoub @geeknoid @xakep139
Microsoft Reviewers: Open in CodeFlow