LoggingSession LoggingSession LoggingSession LoggingSession Class

Represents the destination of logged messages from LoggingChannel instances.

Syntax

Declaration

public sealed class LoggingSessionpublic sealed class LoggingSessionPublic NotInheritable Class LoggingSessionpublic sealed class LoggingSession

Remarks

Use the LoggingSession class to log messages and data to an in-memory circular buffer as your app runs. Use the SaveToFileAsync(IStorageFolder, String) method to save the buffer to a file. You can view the log files by using the Windows Performance Toolkit (WPT) and other utilities like tracerpt.exe.

LoggingSession instances keep logged messages in memory until the SaveToFileAsync(IStorageFolder, String) method is called. This enables on-demand saving of events until the app saves the in-memory messages.

Add LoggingChannel instances to a LoggingSession, and call LoggingSession instance methods to remove channels, dispose, and perform other operations.

LoggingSession records the most recent 260KB of events, after which it will begin overwriting older events.

You cannot have more than one session with the same name. In addition, each app is limited to 4 sessions total.

Constructors summary

Initializes a new instance of the LoggingSession class.

Properties summary

Gets the name of the logging session.

Methods summary

Adds a logging channel to the current logging session.

Adds a logging channel with the specified logging level to the current logging session.

Ends the current logging session.

Removes the specified logging channel from the current logging session.

Saves the current logging session to a file.

Constructors

  • LoggingSession(String)
    LoggingSession(String)
    LoggingSession(String)
    LoggingSession(String)

    Initializes a new instance of the LoggingSession class.

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

    Parameters

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

      The name of the logging session.

Properties

  • Name
    Name
    Name
    Name

    Gets the name of the logging session.

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

    Property Value

    • string
      string
      string
      string

      The session name.

Methods

  • AddLoggingChannel(ILoggingChannel)
    AddLoggingChannel(ILoggingChannel)
    AddLoggingChannel(ILoggingChannel)
    AddLoggingChannel(ILoggingChannel)

    Adds a logging channel to the current logging session.

    public void AddLoggingChannel(ILoggingChannel loggingChannel)public void AddLoggingChannel(ILoggingChannel loggingChannel)Public Function AddLoggingChannel(loggingChannel As ILoggingChannel) As voidpublic void AddLoggingChannel(ILoggingChannel loggingChannel)

    Parameters

  • AddLoggingChannel(ILoggingChannel, LoggingLevel)
    AddLoggingChannel(ILoggingChannel, LoggingLevel)
    AddLoggingChannel(ILoggingChannel, LoggingLevel)
    AddLoggingChannel(ILoggingChannel, LoggingLevel)

    Adds a logging channel with the specified logging level to the current logging session.

    public void AddLoggingChannel(ILoggingChannel loggingChannel, LoggingLevel maxLevel)public void AddLoggingChannel(ILoggingChannel loggingChannel, LoggingLevel maxLevel)Public Function AddLoggingChannel(loggingChannel As ILoggingChannel, maxLevel As LoggingLevel) As voidpublic void AddLoggingChannel(ILoggingChannel loggingChannel, LoggingLevel maxLevel)

    Parameters

    Remarks

    You can also use this function to change the level at which a channel is added to a session; to do so, call AddLoggingChannel, using the existing logging channel, but with the updated level.

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

    Ends the current logging session.

    public void Close()public void Close()Public Function Close() As voidpublic void Close()
  • RemoveLoggingChannel(ILoggingChannel)
    RemoveLoggingChannel(ILoggingChannel)
    RemoveLoggingChannel(ILoggingChannel)
    RemoveLoggingChannel(ILoggingChannel)

    Removes the specified logging channel from the current logging session.

    public void RemoveLoggingChannel(ILoggingChannel loggingChannel)public void RemoveLoggingChannel(ILoggingChannel loggingChannel)Public Function RemoveLoggingChannel(loggingChannel As ILoggingChannel) As voidpublic void RemoveLoggingChannel(ILoggingChannel loggingChannel)

    Parameters

  • SaveToFileAsync(IStorageFolder, String)
    SaveToFileAsync(IStorageFolder, String)
    SaveToFileAsync(IStorageFolder, String)
    SaveToFileAsync(IStorageFolder, String)

    Saves the current logging session to a file.

    public IAsyncOperation<StorageFile> SaveToFileAsync(IStorageFolder folder, String fileName)public IAsyncOperation<StorageFile> SaveToFileAsync(IStorageFolder folder, String fileName)Public Function SaveToFileAsync(folder As IStorageFolder, fileName As String) As IAsyncOperation( Of StorageFile )public IAsyncOperation<StorageFile> SaveToFileAsync(IStorageFolder folder, String fileName)

    Parameters

    Returns

    • When this method completes, it returns the new file as a StorageFile.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

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

Details

Assembly

Windows.Foundation.Diagnostics.dll