TraceListener.Attributes 属性

定义

获取应用程序配置文件中定义的自定义跟踪侦听器特性。

C#
public System.Collections.Specialized.StringDictionary Attributes { get; }

属性值

包含自定义跟踪侦听器特性的 StringDictionary

注解

TraceListener 类继承的类可以通过重写 GetSupportedAttributes 方法并返回自定义属性名称的字符串数组来添加自定义属性。 属性 Attributes 标识在应用程序的配置文件中引用的自定义属性。 例如,在以下配置文件摘录中 DelimitedListTraceListener 引用了自定义属性“delimiter”。 在这种情况下, Attributes 属性返回一个 StringDictionary 包含字符串“delimiter”的 。

XML
<listeners>  
  <add name="delimitedListener"   
    type="System.Diagnostics.DelimitedListTraceListener"   
    delimiter=":"   
    initializeData="delimitedOutput.txt"   
    traceOutputOptions="ProcessId, DateTime" />  
  <remove name="Default" />  
</listeners>  

未引用的自定义属性不枚举。 有关更多信息,请参见 GetSupportedAttributes 方法。

适用于

产品 版本
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1