Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

Database.Log Property

Definition

Namespace:
System.Data.Entity
Assembly:
EntityFramework.dll

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Set this property to log the SQL generated by the DbContext to the given delegate. For example, to log to the console, set this property to Write(String).

public Action<string> Log { get; set; }
member this.Log : Action<string> with get, set
Public Property Log As Action(Of String)

Property Value

Remarks

The format of the log text can be changed by creating a new formatter that derives from DatabaseLogFormatter and setting it with SetDatabaseLogFormatter(Func<DbContext,Action<String>,DatabaseLogFormatter>). For more low-level control over logging/interception see IDbCommandInterceptor and DbInterception.

Applies to


Feedback

Was this page helpful?