TagNameAttribute 类

定义

定义要用于记录的参数或属性的标记名称。

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
继承
TagNameAttribute
属性

示例

[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);

注解

默认情况下,标记名称与相应的参数或属性相同。 可以使用此属性替代默认值并提供自定义标记名称。

构造函数

名称 说明
TagNameAttribute(String)

初始化 TagNameAttribute 类的新实例。

属性

名称 说明
Name

获取记录参数或属性时要使用的标记的名称。

适用于

另请参阅