Database.Log Property

 

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.

Namespace:   System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

public Action<string> Log { get; set; }

Property Value

Type: System.Action<String>

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