Entity Framework在使用时,很多时间操纵的是Model,并没有写sql语句,有时候为了调试或优化等,又需要追踪Entity framework自动生成的sql(最好还能记录起来,方便出错时排查) 方式一: 通过System.Data.Entity.DataBase.Log属性指定一个无返回值的委托,来实现记录日志的功能 public partial class EFContext<T> : DbContext where T : class { public EFContext(
有两种方法可以记录执行的SQl语句: 使用DbContext.Database.Log属性 实现IDbCommandInterceptor接口 一 使用DbContext.Database.Log属性 下面截图显示了Database属性和Log属性,可以看出这个属性是一个委托,类型为Action<string> 对Log属性的解释为: Set this property to log the SQL generated by the System.Data.Entity.DbContext t
MySQL监控全部执行过的sql语句 查看是否开启日志记录show variables like “general_log%” ; +——————+———-+|Variable_name|Value|+——————+———-+|general_log|OFF||general_log_file|/data0/logs/mysql/general.log|+——————+———-+ OFF 关闭ON 开启 临时开启日志记录set global general_log=’ON’ ; 这时执行的所有s
oracle 监控执行的sql语句 select * from v$sqlarea a where module='PL/SQL Developer' order by a.FIRST_LOAD_TIME desc select * from v$sqlarea a where module='PL/SQL Developer' order by a.FIRST_LOAD_TIME desc 监视oracle的执行sql情况: select q.sql_text from v$session s
http://www.cnblogs.com/linhaifeng/articles/7372774.html 一 SELECT语句关键字的定义顺序 SELECT DISTINCT <select_list> FROM <left_table> <join_type> JOIN <right_table> ON <join_condition> WHERE <where_condition> GROUP BY <group_by
查看日志配置是否打开 SHOW VARIABLES LIKE "general_log%"; SET GLOBAL general_log = 'ON'; 打开日志 SET GLOBAL general_log = 'ON'; 查看执行的sqltail -f /var/lib/mysql/general_sql.log