-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
LogPropertiesAttribute.Transitive + LogPropertiesAttribute.OmitReferenceName not working as expected. #10796
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
1 similar comment
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/area-extensions-logging |
OmitReferenceName is not transitive in nature. In general [LogProperties] stuff only applies to the current context. To strip out field names like _Metadata, you would need to put a [LogProperties] attribute definition on the _Metadata field and set OmitReferenceName=true there. I think that should give you the shape of log output you're looking for. |
Oh, then sure, the docs could definitely be expanded to be more explicit about what's going on there. This blog post has some good details: https://andrewlock.net/behind-logproperties-and-the-new-telemetry-logging-source-generator/. The reference docs can use a bit more details, but ideally this would get captured in some examples and higher-level docs. |
Type of issue
Code doesn't work
Description
Hi,
I'm using both LogPropertiesAttribute.Transitive = true and LogPropertiesAttribute.OmitReferenceName = true, but the log still contains the field name like _Metadata.RegionScope":"WW". I would expect the inner object to be printed like _Metadata: {RegionScope":"WW"}.
full example:
the log:
{"Timestamp":"2024-12-31T10:24:22.7589889Z","Message":"","LogLevel":"Information","@r":[""],"_Metadata.TimeGenerated":"2024-12-31T10:24:22.7035140Z","_Metadata.PartnerRing":"PartnerRingc255eda4-275a-473f-88a4-a65b3c380bd6","_Metadata.Zone":3,"_Metadata.RegionScope":"WW","FlowCorrelationId":"1dbb3e90-b14a-4b57-aa09-2263dcfce38a","PolicyAction":"54d3d054-6e64-4adb-81c6-5bf22a79882b","ServiceApp":"36722f0d-fdee-4c07-afc2-41b783b9fb36"}
in the logging extension:
Page URL
https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.logpropertiesattribute.omitreferencename?view=net-9.0-pp
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/Microsoft.Extensions.Logging/LogPropertiesAttribute.xml
Document Version Independent Id
f553155c-6c2c-7ba3-5c2c-b6741b79e46e
Article author
@dotnet-bot
The text was updated successfully, but these errors were encountered: