DbConfiguration.SetDatabaseLogFormatter 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
從衍生 DbConfiguration 自 之類別的建構函式呼叫這個方法,以設定要搭配 Log 使用的 型 DatabaseLogFormatter 別的處理站。
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")]
protected internal void SetDatabaseLogFormatter (Func<System.Data.Entity.DbContext,Action<string>,System.Data.Entity.Infrastructure.Interception.DatabaseLogFormatter> logFormatterFactory);
member this.SetDatabaseLogFormatter : Func<System.Data.Entity.DbContext, Action<string>, System.Data.Entity.Infrastructure.Interception.DatabaseLogFormatter> -> unit
Protected Friend Sub SetDatabaseLogFormatter (logFormatterFactory As Func(Of DbContext, Action(Of String), DatabaseLogFormatter))
參數
- logFormatterFactory
- Func<DbContext,Action<String>,DatabaseLogFormatter>
將建立格式子實例的委派。
- 屬性
備註
請注意,設定要與此方法搭配使用的格式器類型,會變更使用時 Log 記錄命令的方式。 在記錄任何命令之前,仍然需要將 實例設定 TextWriter 為 Log 。 如需對記錄/攔截的更低階控制,請參閱 IDbCommandInterceptor 和 DbInterception 。 此方法提供為方便且可探索的方式,可將組態新增至 Entity Framework。 在內部運作的方式與使用 AddDependencyResolver 來為 新增適當的解析程式 Func<TResult> 相同。 這表示,如有需要,可以使用自訂解析程式或由 Inversion-of-Control 容器支援的解析程式來達成相同的功能。