Udostępnij za pośrednictwem


LoggingChannel Class

Definition

Represents a source of log messages.

public ref class LoggingChannel sealed : IClosable
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.Diagnostics.ILoggingChannelFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.Diagnostics.ILoggingChannelFactory2, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class LoggingChannel final : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.Diagnostics.ILoggingChannelFactory, 65536, "Windows.Foundation.UniversalApiContract")]
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.Diagnostics.ILoggingChannelFactory2, 65536, "Windows.Foundation.UniversalApiContract")]
class LoggingChannel final : IClosable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.Diagnostics.ILoggingChannelFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.Diagnostics.ILoggingChannelFactory2), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class LoggingChannel : System.IDisposable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.Diagnostics.ILoggingChannelFactory), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.Diagnostics.ILoggingChannelFactory2), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class LoggingChannel : System.IDisposable
function LoggingChannel(name, options, id)
Public NotInheritable Class LoggingChannel
Implements IDisposable
Inheritance
Object Platform::Object IInspectable LoggingChannel
Attributes
Implements

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

The default LoggingLevel is Verbose.

Add LoggingChannel instances to a LoggingSession or a FileLoggingSession to enable logging in your app.

The LogMessage methods provide ways to log simple string messages, while the LogEvent methods provide ways to log more complex tracing data.

Windows 10 Two modes of operation are now supported: Windows 8.1 compatibility mode and the new behavior supported by Windows 10 and later which allows you to log self-describing Event Tracing for Windows (ETW) events without a manifest. + For Windows 8.1 compatibility mode, create the object using the LoggingChannel(String) constructor.

Windows 8.1 compatibility modeWindows 10 and later specific behavior
Some **LoggingChannel** events may reference the 4bd2826e-54a1-4ba9-bf63-92b73ea1ac4a which is the [GUID](/windows/win32/api/guiddef/ns-guiddef-guid) for the **Microsoft-Windows-Diagnostics-LoggingChannel** manifest that is available on Windows 8.1 or later.All events are self-describing. No manifest is required.
The Id property is always 4bd2826e-54a1-4ba9-bf63-92b73ea1ac4a, which is the GUID for the **Microsoft-Windows-Diagnostics-LoggingChannel** manifest.The Id property varies based on how the channel is constructed. If the LoggingChannel(String, LoggingChannelOptions) constructor is used, the **Id** is determined by hashing the name parameter. If the LoggingChannel(String, LoggingChannelOptions, Guid) constructor is used, the specified *id* parameter is used.
Events generated by the **LogMessage**, **LogValuePair**, the LoggingActivity constructors or destructor, or activity.Activity.Close method use manifest-based event encoding. All other events use self-describing TraceLogging event encoding.All events use self-describing TraceLogging event encoding.
The channel provider name is Microsoft-Windows-Diagnostics-LoggingChannel. The channel name is recorded in each event in the payload field **LoggingChannelName**.The channel name is used as the provider name. Events will not have a **LoggingChannelName** field.

Constructors

LoggingChannel(String, LoggingChannelOptions, Guid)

Initializes a new instance of the LoggingChannel class with the specified options and channel ID.

LoggingChannel(String, LoggingChannelOptions)

Initializes a new instance of the LoggingChannel class with the specified options.

LoggingChannel(String)

This constructor creates a LoggingChannel in Windows 8.1 compatibility mode.

Properties

Enabled

Gets a value that indicates whether at least one session is logging events from this channel.

Id

Returns the provider identifier for this channel.

Level

Gets the minimum level at which any session is listening to events from this channel.

Name

Gets the name of the current LoggingChannel.

Methods

Close()

Ends logging on the current logging channel.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

IsEnabled()

Indicates whether at least one session is listening for events from the channel.

IsEnabled(LoggingLevel, Int64)

Indicates whether at least one session is listening for events with the specified level and keywords from this channel.

IsEnabled(LoggingLevel)

Indicates whether at least one session is listening for events with the specified event severity level from the channel.

LogEvent(String, LoggingFields, LoggingLevel, LoggingOptions)

Logs an event with the specified name, fields, level, and options.

LogEvent(String, LoggingFields, LoggingLevel)

Logs an event with the specified name, fields, and level.

LogEvent(String, LoggingFields)

Logs an event with the specified name and fields.

LogEvent(String)

Logs an event with the specified name.

LogMessage(String, LoggingLevel)

Logs a message to the current LoggingChannel with the specified LoggingLevel.

LogMessage(String)

Logs a message to the current LoggingChannel.

LogValuePair(String, Int32, LoggingLevel)

Logs data to the current LoggingChannel with the specified LoggingLevel.

LogValuePair(String, Int32)

Logs data to the current LoggingChannel.

StartActivity(String, LoggingFields, LoggingLevel, LoggingOptions)

Writes an activity start event with the specified fields, level, and options, and creates a LoggingActivity object.

StartActivity(String, LoggingFields, LoggingLevel)

Writes an activity start event with the specified fields and level, and creates a LoggingActivity object.

StartActivity(String, LoggingFields)

Writes an activity start event with the specified fields and creates a LoggingActivity object.

StartActivity(String)

Writes an activity start event and creates a LoggingActivity object.

Events

LoggingEnabled

Raised when the logging channel is attached to a LoggingSession or other event tracing and debugging tools.

Applies to

See also