Поделиться через


TagNameAttribute Class

Definition

Defines the tag name to use for a logged parameter or property.

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
Inheritance
TagNameAttribute
Attributes

Examples

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

Remarks

By default, the tag name is the same as the respective parameter or property. You can use this attribute to override the default and provide a custom tag name.

Constructors

TagNameAttribute(String)

Initializes a new instance of the TagNameAttribute class.

Properties

Name

Gets the name of the tag to be used when logging the parameter or property.

Applies to

See also