-
Notifications
You must be signed in to change notification settings - Fork 732
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
HttpClientFactory logs - "StatusCode" property is inconsistent with other internal logs #1549
Comments
We have also identified this issue, so we would be very happy to see this completed. |
Agreed, we should be consistent. |
The announcement should include possible workarounds in case users want to continue getting the older data type. |
This has been merged. I'll work on the announcement. |
Thanks for the feedback. This change has been merged for 5.0 and announced officially. If you want to get this behavior in 2.1+ you can follow the steps of the workaround described here, and customize the logging behavior to your liking. |
Info
Internal handlers used in the
HttpClientFactory
pattern, the LoggingHttpMessageHandler and the LoggingScopeHttpMessageHandler, create log messages after successful http requests in the following formatsLoggingHttpMessageHandler:
LoggingScopeHttpMessageHandler:
An example of these are:
As you can see, the
StatusCode
property is sent as the textual representation of the status code instead of the integer version (e.g.200
instead ofOK
).This conflicts with an internal log, the HostingRequestFinishedLog, which generates logs in the following format:
An example of this is:
Here, the
StatusCode
property is the integer representation of the status code and not the text like it is in the above two message handlers.Problem
This conflict is causing an issue with dropped log messages in our system because we send our logs to Elasticsearch (via the Serilog sink), and Elasticsearch requires consistent types for properties with the same name.
In this case, if a
HostingRequestFinishedLog
log is sent first, Elasticsearch maps theStatusCode
property to along
and all the logs from the two message handlers are discarded due to theirStatusCode
property being the wrong type. Vice versa if the message handlers get their log in first.I think the message handler logs should be consistent with the internal framework logs and send their
StatusCode
property as an integer, it would resolve this conflict and I generally think the integer is more useful anyway. I'd be happy to submit a PR for this others agree.The text was updated successfully, but these errors were encountered: