LoggingChannel LoggingChannel LoggingChannel LoggingChannel Class

Represents a source of log messages.

Syntax

Declaration

public sealed class LoggingChannelpublic sealed class LoggingChannelPublic NotInheritable Class LoggingChannelpublic sealed class LoggingChannel

Remarks

The default LoggingLevel is Verbose.

Add @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions) 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. + For Windows 8.1 compatibility mode, create the object using the @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions) constructor.

  • For Windows 10 and later specific behavior, create the object using the @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions) or @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions,System.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 @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions) constructor is used, the Id is determined by hashing the name parameter. If the @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions,System.Guid) constructor is used, the specified id parameter is used.
Events generated by the LogMessage, LogValuePair, the @Windows.Foundation.Diagnostics.LoggingActivity.#ctor(System.String,Windows.Foundation.Diagnostics.ILoggingChannel,Windows.Foundation.Diagnostics.LoggingLevel) constructors or destructor, or 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 summary

This constructor creates a LoggingChannel in Windows 8.1 compatibility mode.

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

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

Properties summary

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

Returns the provider identifier for this channel.

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

Gets the name of the current LoggingChannel.

Methods summary

Ends logging on the current logging channel.

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

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

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

Logs an event with the specified name.

Logs an event with the specified name and fields.

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

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

Logs a message to the current LoggingChannel.

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

Logs data to the current LoggingChannel.

Logs data to the current LoggingChannel with the specified LoggingLevel.

Writes an activity start event and creates a LoggingActivity object.

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

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

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

Events summary

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

Constructors

  • LoggingChannel(String)
    LoggingChannel(String)
    LoggingChannel(String)
    LoggingChannel(String)

    This constructor creates a LoggingChannel in Windows 8.1 compatibility mode.

    public LoggingChannel(String name)public New(String name)Public Sub New(name As String)public LoggingChannel(String name)

    Parameters

    • name
      System.String
      System.String
      System.String
      System.String

      The name of the logging channel.

    Remarks

    This constructor creates a LoggingChannel in Windows 8.1 compatibility mode. For a description of the differences between Windows 8.1 compatibility mode and the new behavior supported by Windows 10, see LoggingChannel.

    Windows 10 This constructor should only be used if you need compatibility with Windows 8.1. For Windows 10 and later, use @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions) or @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions,System.Guid).

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

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

    public LoggingChannel(String name, LoggingChannelOptions options)public New(String name, LoggingChannelOptions options)Public Sub New(name As String, options As LoggingChannelOptions)public LoggingChannel(String name, LoggingChannelOptions options)

    Parameters

  • 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.

    public LoggingChannel(String name, LoggingChannelOptions options, Guid id)public New(String name, LoggingChannelOptions options, Guid id)Public Sub New(name As String, options As LoggingChannelOptions, id As Guid)public LoggingChannel(String name, LoggingChannelOptions options, Guid id)

    Parameters

Properties

  • Enabled
    Enabled
    Enabled
    Enabled

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

    public bool Enabled { get; }public bool Enabled { get; }Public ReadOnly Property Enabled As boolpublic bool Enabled { get; }

    Property Value

    • bool
      bool
      bool
      bool

      Returns true if at least one session is listening for events from the channel, and otherwise false.

  • Id
    Id
    Id
    Id

    Returns the provider identifier for this channel.

    public Guid Id { get; }public Guid Id { get; }Public ReadOnly Property Id As Guidpublic Guid Id { get; }

    Property Value

    • System.Guid
      System.Guid
      System.Guid
      System.Guid

      The provider identifier for this channel.

    Remarks

    The value of the Id depends on how the LoggingChannel is constructed as described in the following table:

    Constructor usedThe value of Id
    @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String) The channel will be operating in Windows 8.1 compatibility mode and will return 4bd2826e-54a1-4ba9-bf63-92b73ea1ac4a which is the GUID for the Microsoft-Windows-Diagnostics-LoggingChannel manifest.
    @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions) The GUID will be determined by hashing the name parameter passed to the LoggingChannel constructor.
    @Windows.Foundation.Diagnostics.LoggingChannel.#ctor(System.String,Windows.Foundation.Diagnostics.LoggingChannelOptions,System.Guid) The value is the same as the Id parameter passed to the LoggingChannel constructor.

  • Level
    Level
    Level
    Level

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

    public LoggingLevel Level { get; }public LoggingLevel Level { get; }Public ReadOnly Property Level As LoggingLevelpublic LoggingLevel Level { get; }

    Property Value

    Remarks

    This value is only valid if the Enabled property is set to true.

  • Name
    Name
    Name
    Name

    Gets the name of the current LoggingChannel.

    public string Name { get; }public string Name { get; }Public ReadOnly Property Name As stringpublic string Name { get; }

    Property Value

    • string
      string
      string
      string

      The name.

Methods

  • Close()
    Close()
    Close()
    Close()

    Ends logging on the current logging channel.

    public void Close()public void Close()Public Function Close() As voidpublic void Close()
  • IsEnabled()
    IsEnabled()
    IsEnabled()
    IsEnabled()

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

    public bool IsEnabled()public bool IsEnabled()Public Function IsEnabled() As boolpublic bool IsEnabled()

    Returns

    • bool
      bool
      bool
      bool

      Returns true if at least one session is listening for events from the channel, and otherwise false.

    Remarks

    This property is functionally equivalent to Enabled

  • 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.

    public bool IsEnabled(LoggingLevel level)public bool IsEnabled(LoggingLevel level)Public Function IsEnabled(level As LoggingLevel) As boolpublic bool IsEnabled(LoggingLevel level)

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      Returns true if at least one session is listening for events with the specified level from the channel, and otherwise false.

    Remarks

    This property is equivalent to channel.Enabled && channel.Level <= level.

  • 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.

    public bool IsEnabled(LoggingLevel level, Int64 keywords)public bool IsEnabled(LoggingLevel level, Int64 keywords)Public Function IsEnabled(level As LoggingLevel, keywords As Int64) As boolpublic bool IsEnabled(LoggingLevel level, Int64 keywords)

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      Returns true if at least one session is listening for events with the specified level and keywords from the channel, and otherwise false.

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

    Logs an event with the specified name.

    public void LogEvent(String eventName)public void LogEvent(String eventName)Public Function LogEvent(eventName As String) As voidpublic void LogEvent(String eventName)

    Parameters

    • eventName
      System.String
      System.String
      System.String
      System.String

      The name for this event.

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

    Logs an event with the specified name and fields.

    public void LogEvent(String eventName, LoggingFields fields)public void LogEvent(String eventName, LoggingFields fields)Public Function LogEvent(eventName As String, fields As LoggingFields) As voidpublic void LogEvent(String eventName, LoggingFields fields)

    Parameters

  • 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.

    public void LogEvent(String eventName, LoggingFields fields, LoggingLevel level)public void LogEvent(String eventName, LoggingFields fields, LoggingLevel level)Public Function LogEvent(eventName As String, fields As LoggingFields, level As LoggingLevel) As voidpublic void LogEvent(String eventName, LoggingFields fields, LoggingLevel level)

    Parameters

  • 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.

    public void LogEvent(String eventName, LoggingFields fields, LoggingLevel level, LoggingOptions options)public void LogEvent(String eventName, LoggingFields fields, LoggingLevel level, LoggingOptions options)Public Function LogEvent(eventName As String, fields As LoggingFields, level As LoggingLevel, options As LoggingOptions) As voidpublic void LogEvent(String eventName, LoggingFields fields, LoggingLevel level, LoggingOptions options)

    Parameters

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

    Logs a message to the current LoggingChannel.

    public void LogMessage(String eventString)public void LogMessage(String eventString)Public Function LogMessage(eventString As String) As voidpublic void LogMessage(String eventString)

    Parameters

    • eventString
      System.String
      System.String
      System.String
      System.String

      The message to log.

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

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

    public void LogMessage(String eventString, LoggingLevel level)public void LogMessage(String eventString, LoggingLevel level)Public Function LogMessage(eventString As String, level As LoggingLevel) As voidpublic void LogMessage(String eventString, LoggingLevel level)

    Parameters

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

    Logs data to the current LoggingChannel.

    public void LogValuePair(String value1, Int32 value2)public void LogValuePair(String value1, Int32 value2)Public Function LogValuePair(value1 As String, value2 As Int32) As voidpublic void LogValuePair(String value1, Int32 value2)

    Parameters

    • value1
      System.String
      System.String
      System.String
      System.String

      The string to associate with value2.

    • value2
      System.Int32
      System.Int32
      System.Int32
      System.Int32

      The value to associate with value1.

    Remarks

    Call the LogValuePair(String, Int32, LoggingLevel) method to log data as a key-value pair to the current LoggingChannel.

  • 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.

    public void LogValuePair(String value1, Int32 value2, LoggingLevel level)public void LogValuePair(String value1, Int32 value2, LoggingLevel level)Public Function LogValuePair(value1 As String, value2 As Int32, level As LoggingLevel) As voidpublic void LogValuePair(String value1, Int32 value2, LoggingLevel level)

    Parameters

    • value1
      System.String
      System.String
      System.String
      System.String

      The string to associate with value2.

    • value2
      System.Int32
      System.Int32
      System.Int32
      System.Int32

      The value to associate with value1.

    • level

      The logging level.

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

    Writes an activity start event and creates a LoggingActivity object.

    public LoggingActivity StartActivity(String startEventName)public LoggingActivity StartActivity(String startEventName)Public Function StartActivity(startEventName As String) As LoggingActivitypublic LoggingActivity StartActivity(String startEventName)

    Parameters

    • startEventName
      System.String
      System.String
      System.String
      System.String

      The name for this event.

    Returns

  • 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.

    public LoggingActivity StartActivity(String startEventName, LoggingFields fields)public LoggingActivity StartActivity(String startEventName, LoggingFields fields)Public Function StartActivity(startEventName As String, fields As LoggingFields) As LoggingActivitypublic LoggingActivity StartActivity(String startEventName, LoggingFields fields)

    Parameters

    Returns

  • 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.

    public LoggingActivity StartActivity(String startEventName, LoggingFields fields, LoggingLevel level)public LoggingActivity StartActivity(String startEventName, LoggingFields fields, LoggingLevel level)Public Function StartActivity(startEventName As String, fields As LoggingFields, level As LoggingLevel) As LoggingActivitypublic LoggingActivity StartActivity(String startEventName, LoggingFields fields, LoggingLevel level)

    Parameters

    Returns

  • 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.

    public LoggingActivity StartActivity(String startEventName, LoggingFields fields, LoggingLevel level, LoggingOptions options)public LoggingActivity StartActivity(String startEventName, LoggingFields fields, LoggingLevel level, LoggingOptions options)Public Function StartActivity(startEventName As String, fields As LoggingFields, level As LoggingLevel, options As LoggingOptions) As LoggingActivitypublic LoggingActivity StartActivity(String startEventName, LoggingFields fields, LoggingLevel level, LoggingOptions options)

    Parameters

    Returns

    Remarks

    If you provide options, LoggingOptions.ActivityId and LoggingOptions.Opcode are ignored because the new LoggingActivity object's options will be set as follows:

    The Id is automatically generated.

    The opcode is set to LoggingOptions.Opcode.Start

Events

  • LoggingEnabled
    LoggingEnabled
    LoggingEnabled
    LoggingEnabled

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

    public event TypedEventHandler LoggingEnabledpublic event TypedEventHandler LoggingEnabledPublic Event LoggingEnabledpublic event TypedEventHandler LoggingEnabled

    Remarks

    The LoggingEnabled event is raised when a channel is consumed by a session within the app's process, or by a kernel-mode ETW session started with a debugging or performance analysis tool.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ThreadingAttribute

Details

Assembly

Windows.Foundation.Diagnostics.dll