Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

LoggingChannel class

Represents a source of log messages.

Syntax


var loggingChannel = new Windows.Foundation.Diagnostics.LoggingChannel(string);
var loggingChannel = new Windows.Foundation.Diagnostics.LoggingChannel(string, loggingChannelOptions);
var loggingChannel = new Windows.Foundation.Diagnostics.LoggingChannel(string, loggingChannelOptions, guid);

Members

The LoggingChannel class has these types of members:

Constructors

The LoggingChannel class has these constructors.

ConstructorDescription
LoggingChannel(String) This constructor creates a LoggingChannel in Windows 8.1 compatibility mode.
LoggingChannel(String,LoggingChannelOptions) Initializes a new instance of the LoggingChannel class with the specified options.
LoggingChannel(String,LoggingChannelOptions,Guid) Initializes a new instance of the LoggingChannel class with the specified options and channel ID.

 

Events

The LoggingChannel class has these events.

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

 

Methods

The LoggingChannel class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
Close Ends logging on the current logging channel.
Dispose Performs 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) Indicates whether at least one session is listening for events with the specified event severity level 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.
LogEvent(String) Logs an event with the specified name.
LogEvent(String,LoggingFields) Logs an event with the specified name and fields.
LogEvent(String,LoggingFields,LoggingLevel) Logs an event with the specified name, fields, and level.
LogEvent(String,LoggingFields,LoggingLevel,LoggingOptions) Logs an event with the specified name, fields, level, and options.
LogMessage(String) Logs a message to the current LoggingChannel.
LogMessage(String,LoggingLevel) Logs a message to the current LoggingChannel with the specified LoggingLevel.
LogValuePair(String,Int32) Logs data to the current LoggingChannel.
LogValuePair(String,Int32,LoggingLevel) Logs data to the current LoggingChannel with the specified LoggingLevel.
StartActivity(String) Writes an activity start event and creates a LoggingActivity object.
StartActivity(String,LoggingFields) Writes an activity start event with the specified fields 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,LoggingLevel,LoggingOptions) Writes an activity start event with the specified fields, level, and options, and creates a LoggingActivity object.

 

Properties

The LoggingChannel class has these properties.

PropertyAccess typeDescription

Enabled

Read-only

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

Id

Read-only

Returns the provider identifier for this channel.

Level

Read-only

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

Name

Read-only

Gets the name of the current LoggingChannel.

 

Remarks

The default LoggingLevel is Verbose.

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

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.

The differences between these two modes are:

Windows 8.1 compatibility mode Windows 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.

 

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Foundation.Diagnostics
Windows::Foundation::Diagnostics [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8.1 [Windows Store apps only]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Foundation.Diagnostics
Windows::Foundation::Diagnostics [C++]

Metadata

Windows.winmd

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06030000)]

See also

ILoggingTarget
LoggingSession
FileLoggingSession
Object
ILoggingChannel
IClosable
Logging sample (Windows 10)

 

 

Show: