語言

DatabaseLogger 類別

定義

一個簡單的記錄器,用來將 SQL 及其他資料庫操作記錄到主控台或檔案。 記錄器可以註冊在程式碼中,或是在應用程式的 web.config/app.config 檔案中。

public class DatabaseLogger : IDisposable, System.Data.Entity.Infrastructure.Interception.IDbConfigurationInterceptor
type DatabaseLogger = class
    interface IDisposable
    interface IDbConfigurationInterceptor
    interface IDbInterceptor
Public Class DatabaseLogger
Implements IDbConfigurationInterceptor, IDisposable
繼承
DatabaseLogger
實作

建構函式

名稱 Description
DatabaseLogger()

建立一個新的記錄器,將日誌輸出傳送到主控台。

DatabaseLogger(String, Boolean)

建立一個新的記錄器,將日誌輸出傳送到檔案。

DatabaseLogger(String)

建立一個新的記錄器,將日誌輸出傳送到檔案。 如果檔案已經存在,則會被覆寫。

方法

名稱 Description
Dispose()

如果輸出正在寫入檔案,會停止日誌並關閉底層檔案。

Dispose(Boolean)

如果輸出正在寫入檔案,會停止日誌並關閉底層檔案。

StartLogging()

開始記錄。 如果日誌已經開始,此方法可 no-op。

StopLogging()

停止記錄。 如果沒有開始記錄,這種方法 no-op。

明確介面實作

名稱 Description
IDbConfigurationInterceptor.Loaded(DbConfigurationLoadedEventArgs, DbConfigurationInterceptionContext)

當該記錄器註冊時,於實體框架初始化時呼叫以開始記錄。 作為 IDbInterceptor。

適用於