Edit

Share via


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
Source:
DiagnosticSource.cs

Provides a generic way of logging complex payloads.

public:
 abstract void Write(System::String ^ name, System::Object ^ value);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of object being written to DiagnosticSource cannot be discovered statically.")]
public abstract void Write(string name, object? value);
public abstract void Write(string name, object? value);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of object being written to DiagnosticSource cannot be discovered statically.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("DiagnosticSource may require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")]
public abstract void Write(string name, object? value);
public abstract void Write(string name, object value);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of object being written to DiagnosticSource cannot be discovered statically.")>]
abstract member Write : string * obj -> unit
abstract member Write : string * obj -> unit
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("The type of object being written to DiagnosticSource cannot be discovered statically.")>]
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("DiagnosticSource may require creating new generic types or methods, which requires creating code at runtime. This may not work when AOT compiling.")>]
abstract member Write : string * obj -> unit
Public MustOverride Sub Write (name As String, value As Object)

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 that contains several subvalues.

Attributes

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

Write<T>(String, T)

Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
Source:
DiagnosticSource.cs
public:
generic <typename T>
 void Write(System::String ^ name, T value);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Only the properties of the T type will be preserved. Properties of referenced types and properties of derived types may be trimmed.")]
public void Write<T>(string name, T value);
public void Write<T>(string name, T value);
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("Only the properties of the T type will be preserved. Properties of referenced types and properties of derived types may be trimmed.")>]
member this.Write : string * 'T -> unit
member this.Write : string * 'T -> unit
Public Sub Write(Of T) (name As String, value As T)

Type Parameters

T

Parameters

name
String
value
T
Attributes

Applies to