LoggingSession LoggingSession LoggingSession LoggingSession LoggingSession Class

Definition

Represents the destination of logged messages from LoggingChannel instances.

public : sealed class LoggingSession : ILoggingSession, IClosable
struct winrt::Windows::Foundation::Diagnostics::LoggingSession : ILoggingSession, IClosable
public sealed class LoggingSession : ILoggingSession, IDisposable
Public NotInheritable Class LoggingSession Implements ILoggingSession, IDisposable
var loggingSession = new loggingSession(name);
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Use the LoggingSession class to log messages and data to an in-memory circular buffer as your app runs. Use the SaveToFileAsync 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 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

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

Initializes a new instance of the LoggingSession class.

public : LoggingSession(Platform::String name)
LoggingSession(winrt::hstring name) const;
public LoggingSession(String name)
Public Sub New(name As String)
var loggingSession = new loggingSession(name);
Parameters
name
String String String

The name of the logging session.

Properties

Name Name Name Name Name

Gets the name of the logging session.

public : Platform::String Name { get; }
winrt::hstring Name();
public string Name { get; }
Public ReadOnly Property Name As string
var string = loggingSession.name;
Value
string string string

The session name.

Methods

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

Adds a logging channel to the current logging session.

public : void AddLoggingChannel(ILoggingChannel loggingChannel)
void AddLoggingChannel(ILoggingChannel loggingChannel) const;
public void AddLoggingChannel(ILoggingChannel loggingChannel)
Public Function AddLoggingChannel(loggingChannel As ILoggingChannel) As void
loggingSession.addLoggingChannel(loggingChannel);
Parameters
loggingChannel
ILoggingChannel ILoggingChannel ILoggingChannel

The logging channel to add.

See Also

AddLoggingChannel(ILoggingChannel, LoggingLevel) 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)
void AddLoggingChannel(ILoggingChannel loggingChannel, LoggingLevel maxLevel) const;
public void AddLoggingChannel(ILoggingChannel loggingChannel, LoggingLevel maxLevel)
Public Function AddLoggingChannel(loggingChannel As ILoggingChannel, maxLevel As LoggingLevel) As void
loggingSession.addLoggingChannel(loggingChannel, maxLevel);
Parameters
loggingChannel
ILoggingChannel ILoggingChannel ILoggingChannel

The logging channel to add.

maxLevel
LoggingLevel LoggingLevel LoggingLevel

The logging level for loggingChannel.

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.

See Also

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

Ends the current logging session.

public : void Close()
void Close() const;
// This member is not implemented in C#
' This member is not implemented in VB.Net
// This member is not implemented in JavaScript

Dispose() Dispose() Dispose()

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

// This member is not implemented in C++/CX
void Dispose()
Sub Dispose

RemoveLoggingChannel(ILoggingChannel) RemoveLoggingChannel(ILoggingChannel) RemoveLoggingChannel(ILoggingChannel) RemoveLoggingChannel(ILoggingChannel) RemoveLoggingChannel(ILoggingChannel)

Removes the specified logging channel from the current logging session.

public : void RemoveLoggingChannel(ILoggingChannel loggingChannel)
void RemoveLoggingChannel(ILoggingChannel loggingChannel) const;
public void RemoveLoggingChannel(ILoggingChannel loggingChannel)
Public Function RemoveLoggingChannel(loggingChannel As ILoggingChannel) As void
loggingSession.removeLoggingChannel(loggingChannel);
Parameters
loggingChannel
ILoggingChannel ILoggingChannel ILoggingChannel

The logging channel to remove.

SaveToFileAsync(IStorageFolder, String) 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, Platform::String fileName)
IAsyncOperation<StorageFile> SaveToFileAsync(IStorageFolder folder, winrt::hstring fileName) const;
public IAsyncOperation<StorageFile> SaveToFileAsync(IStorageFolder folder, String fileName)
Public Function SaveToFileAsync(folder As IStorageFolder, fileName As String) As IAsyncOperation( Of StorageFile )
Windows.Foundation.Diagnostics.LoggingSession.saveToFileAsync(folder, fileName).done( /* Your success and error handlers */ );
Parameters
folder
IStorageFolder IStorageFolder IStorageFolder

The folder that contains the log file.

fileName
String String String

The name of the log file.

Returns

See Also