Share via


LoggingSession 類別

定義

表示 來自 LoggingChannel 實例之記錄訊息的目的地。

public ref class LoggingSession sealed : ILoggingSession, IClosable
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.Diagnostics.ILoggingSessionFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class LoggingSession final : ILoggingSession, IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.Foundation.Diagnostics.ILoggingSessionFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class LoggingSession final : ILoggingSession, IClosable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.Diagnostics.ILoggingSessionFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class LoggingSession : System.IDisposable, ILoggingSession
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.Foundation.Diagnostics.ILoggingSessionFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class LoggingSession : System.IDisposable, ILoggingSession
function LoggingSession(name)
Public NotInheritable Class LoggingSession
Implements IDisposable, ILoggingSession
繼承
Object Platform::Object IInspectable LoggingSession
屬性
實作

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

備註

使用 LoggingSession 類別,在應用程式執行時,將訊息和資料記錄到記憶體內部迴圈緩衝區。 使用 SaveToFileAsync 方法,將緩衝區儲存至檔案。 您可以使用 Windows Performance Toolkit (WPT) 和其他公用程式來檢視記錄檔,例如 tracerpt.exe。

LoggingSession 實例會將記錄的訊息保留在記憶體中,直到呼叫 SaveToFileAsync 方法為止。 這可讓您視需要儲存事件,直到應用程式儲存記憶體內部訊息為止。

LoggingChannel 實例新增至 LoggingSession,並呼叫 LoggingSession 實例方法來移除通道、處置和執行其他作業。

LoggingSession 會記錄最近 260 KB 的事件,之後就會開始覆寫較舊的事件。

您無法有多個具有相同名稱的會話。 此外,每個應用程式總計限制為 4 個會話。

建構函式

LoggingSession(String)

初始化 LoggingSession 類別的新實例。

屬性

Name

取得記錄會話的名稱。

方法

AddLoggingChannel(ILoggingChannel)

將記錄通道新增至目前的記錄會話。

AddLoggingChannel(ILoggingChannel, LoggingLevel)

將具有指定記錄層級的記錄通道新增至目前的記錄會話。

Close()

結束目前的記錄會話。

Dispose()

執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。

RemoveLoggingChannel(ILoggingChannel)

從目前的記錄會話中移除指定的記錄通道。

SaveToFileAsync(IStorageFolder, String)

將目前的記錄會話儲存至檔案。

適用於

另請參閱