اقرأ باللغة الإنجليزية تحرير

مشاركة عبر


DiagnosticSource.Write Method

Definition

Overloads

Write(String, Object)

Provides a generic way of logging complex payloads.

Write<T>(String, T)

Write(String, Object)

Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs

Provides a generic way of logging complex payloads.

C#
public abstract void Write(string name, object? value);
C#
public abstract void Write(string name, object value);

Parameters

name
String

The name of the event being written.

value
Object

An object that represents the value being passed as a payload for the event. This is often an anonymous type which contains several sub-values.

Remarks

Each notification is given a name that identifies it, as well as an object (typically an anonymous type) that provides arbitrary information to pass to the notification.

name should be short. Don't use a fully qualified name unless you have to to avoid ambiguity, since name must be globally unique. Typically, componentName.eventName, where componentName and eventName are strings less than 10 characters, are a good compromise.

Notification names should not have . in them because component names have dots, and for them both to have dots leads to ambiguity. We suggest that you use _ instead.

Assume that listeners will use string prefixing to filter groups. Therefore, having a hierarchy of component names is a good practice.

Applies to

.NET 10 والإصدارات الأخرى
منتج الإصدارات
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

Write<T>(String, T)

Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
C#
public void Write<T>(string name, T value);

Type Parameters

T

Parameters

name
String
value
T

Applies to

.NET 10 والإصدارات الأخرى
منتج الإصدارات
.NET 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)