Skip to content

LogPropertiesAttribute.Transitive + LogPropertiesAttribute.OmitReferenceName not working as expected. #10796

Open
@noamshim

Description

@noamshim

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions