TagNameAttribute 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
定义要用于记录的参数或属性的标记名称。
public ref class TagNameAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property)]
[System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")]
public sealed class TagNameAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Parameter | System.AttributeTargets.Property)>]
[<System.Diagnostics.Conditional("CODE_GENERATION_ATTRIBUTES")>]
type TagNameAttribute = class
inherit Attribute
Public NotInheritable Class TagNameAttribute
Inherits Attribute
- 继承
- 属性
示例
[LoggerMessage(1, LogLevel.Information, "My custom tag name: {my.custom.tagname}")]
public static partial void LogMyCustomTagName(
this ILogger logger,
[TagName("my.custom.tagname")] string name);
注解
默认情况下,标记名称与相应的参数或属性相同。 可以使用此属性替代默认值并提供自定义标记名称。