extensions
extensions copied to clipboard
Specifying custom tag names does not work
I am trying to use custom names for my properties however that attribute is not working. For reference my log generator is as follows:
[LoggerMessage(
EventId = 0,
Message = "Have recorded metric")]
public static partial void RecordMetric(
#pragma warning disable EXTEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
this ILogger logger, LogLevel logLevel, [LogProperties(SkipNullProperties = true)] [TagName("test")] MetricDef metric, [LogProperties(SkipNullProperties = true)] MetricDescriptorDef descriptor, [LogProperties(SkipNullProperties = true)] EventDef @event);
#pragma warning restore EXTEXP0003 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
The code compiles but the property doesn't change name. to reflect.
Let me know if this needs to become a feature request.
cc: @xakep139
@geeknoid is this behavior intended? @thompson-tomo can you please provide more clarification, what's your expected behavior? and what's the current behavior?
Sorry, I didn't see this earlier.
@thompson-tomo if you still remember the issue, could you clarity a bit? Are you expecting that the "metric" parameter shows up as a value named as "test"? Can you show the output of this log statement to see what actually comes out?
That is correct, I am expecting the metric property to be named tag. Will come back in the coming days with the log output etc
I tested your code, and created a dummy class for MetricDef to see what the output will be, and here's what I got
This is the behavior you're describing:
However, if you add a placeholder in the logging message with the tagName like this "Have recorded metric {test}", you will find the metric property to be "test".
Here's the behavior when I added the placeholder.
Is this what you need?