DiagnosticSource.Write Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Provides a generic way of logging complex payloads.
public:
abstract void Write(System::String ^ name, System::Object ^ value);
public abstract void Write (string name, object? value);
public abstract void Write (string name, object value);
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 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
Write<T>(String, T)
- Source:
- DiagnosticSource.cs
- Source:
- DiagnosticSource.cs
public:
generic <typename T>
void Write(System::String ^ name, T value);
public void Write<T> (string name, T value);
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