Skip to content
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

Open
noamshim opened this issue Dec 31, 2024 · 2 comments
Labels
needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners untriaged New issue has not been triaged by the area owner

Comments

@noamshim
Copy link

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:

[LoggerMessage( Level = LogLevel.Information, EventId = EventConstants.GeneratingRoxyStreamOperationEventId, EventName = EventConstants.GeneratingRoxyStreamOperationEventName)] public static partial void LogRoxyStreamOperationEvent( this ILogger logger, [LogProperties(OmitReferenceName = true, Transitive = true)] in RoxyStreamOperationEvent roxyStreamOperationEvent);

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

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 31, 2024
Copy link

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
Copy link

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.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

1 participant