LoggingChannel LoggingChannel LoggingChannel LoggingChannel LoggingChannel Class

Definition

Represents a source of log messages.

public : sealed class LoggingChannel : ILoggingChannel, ILoggingChannel2, ILoggingTarget, IClosable
struct winrt::Windows::Foundation::Diagnostics::LoggingChannel : ILoggingChannel, ILoggingChannel2, ILoggingTarget, IClosable
public sealed class LoggingChannel : ILoggingChannel, ILoggingChannel2, ILoggingTarget, IDisposable
Public NotInheritable Class LoggingChannel Implements ILoggingChannel, ILoggingChannel2, ILoggingTarget, IDisposable
var loggingChannel = new loggingChannel(name);
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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.

  • For Windows 10 and later specific behavior, create the object using the LoggingChannel(String, LoggingChannelOptions) or LoggingChannel(String, LoggingChannelOptions, Guid) constructor. The differences between these two modes are:
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 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) LoggingChannel(String) LoggingChannel(String) LoggingChannel(String) LoggingChannel(String)

This constructor creates a LoggingChannel in Windows 8.1 compatibility mode.

LoggingChannel(String, LoggingChannelOptions) LoggingChannel(String, LoggingChannelOptions) LoggingChannel(String, LoggingChannelOptions) LoggingChannel(String, LoggingChannelOptions) LoggingChannel(String, LoggingChannelOptions)

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

LoggingChannel(String, LoggingChannelOptions, Guid) LoggingChannel(String, LoggingChannelOptions, Guid) LoggingChannel(String, LoggingChannelOptions, Guid) LoggingChannel(String, LoggingChannelOptions, Guid) LoggingChannel(String, LoggingChannelOptions, Guid)

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

Properties

Enabled Enabled Enabled Enabled Enabled

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

Id Id Id Id Id

Returns the provider identifier for this channel.

Level Level Level Level Level

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

Name Name Name Name Name

Gets the name of the current LoggingChannel.

Methods

Close() Close() Close() Close() Close()

Ends logging on the current logging channel.

Dispose() Dispose() Dispose() Dispose() Dispose()

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

IsEnabled() IsEnabled() IsEnabled() IsEnabled() IsEnabled()

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

IsEnabled(LoggingLevel) IsEnabled(LoggingLevel) IsEnabled(LoggingLevel) IsEnabled(LoggingLevel) IsEnabled(LoggingLevel)

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

IsEnabled(LoggingLevel, Int64) IsEnabled(LoggingLevel, Int64) IsEnabled(LoggingLevel, Int64) IsEnabled(LoggingLevel, Int64) IsEnabled(LoggingLevel, Int64)

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

LogEvent(String) LogEvent(String) LogEvent(String) LogEvent(String) LogEvent(String)

Logs an event with the specified name.

LogEvent(String, LoggingFields) LogEvent(String, LoggingFields) LogEvent(String, LoggingFields) LogEvent(String, LoggingFields) LogEvent(String, LoggingFields)

Logs an event with the specified name and fields.

LogEvent(String, LoggingFields, LoggingLevel) LogEvent(String, LoggingFields, LoggingLevel) LogEvent(String, LoggingFields, LoggingLevel) LogEvent(String, LoggingFields, LoggingLevel) LogEvent(String, LoggingFields, LoggingLevel)

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

LogEvent(String, LoggingFields, LoggingLevel, LoggingOptions) LogEvent(String, LoggingFields, LoggingLevel, LoggingOptions) LogEvent(String, LoggingFields, LoggingLevel, LoggingOptions) LogEvent(String, LoggingFields, LoggingLevel, LoggingOptions) LogEvent(String, LoggingFields, LoggingLevel, LoggingOptions)

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

LogMessage(String) LogMessage(String) LogMessage(String) LogMessage(String) LogMessage(String)

Logs a message to the current LoggingChannel.

LogMessage(String, LoggingLevel) LogMessage(String, LoggingLevel) LogMessage(String, LoggingLevel) LogMessage(String, LoggingLevel) LogMessage(String, LoggingLevel)

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

LogValuePair(String, Int32) LogValuePair(String, Int32) LogValuePair(String, Int32) LogValuePair(String, Int32) LogValuePair(String, Int32)

Logs data to the current LoggingChannel.

LogValuePair(String, Int32, LoggingLevel) LogValuePair(String, Int32, LoggingLevel) LogValuePair(String, Int32, LoggingLevel) LogValuePair(String, Int32, LoggingLevel) LogValuePair(String, Int32, LoggingLevel)

Logs data to the current LoggingChannel with the specified LoggingLevel.

StartActivity(String) StartActivity(String) StartActivity(String) StartActivity(String) StartActivity(String)

Writes an activity start event and creates a LoggingActivity object.

StartActivity(String, LoggingFields) StartActivity(String, LoggingFields) StartActivity(String, LoggingFields) StartActivity(String, LoggingFields) StartActivity(String, LoggingFields)

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

StartActivity(String, LoggingFields, LoggingLevel) StartActivity(String, LoggingFields, LoggingLevel) StartActivity(String, LoggingFields, LoggingLevel) StartActivity(String, LoggingFields, LoggingLevel) StartActivity(String, LoggingFields, LoggingLevel)

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

StartActivity(String, LoggingFields, LoggingLevel, LoggingOptions) StartActivity(String, LoggingFields, LoggingLevel, LoggingOptions) StartActivity(String, LoggingFields, LoggingLevel, LoggingOptions) StartActivity(String, LoggingFields, LoggingLevel, LoggingOptions) StartActivity(String, LoggingFields, LoggingLevel, LoggingOptions)

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

Events

LoggingEnabled LoggingEnabled LoggingEnabled LoggingEnabled LoggingEnabled

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

See Also