Log every SQL query to database in Rails

后端 未结 6 1526
梦毁少年i
梦毁少年i 2020-12-03 17:40

I want to save to a log file some SQL query rails performs, (namely the CREATE, UPDATE and DELETE ones) therefore I need to intercept all queries and then filter them maybe

6条回答
  •  春和景丽
    2020-12-03 18:00

    If you are using mysql I would look into mysqlbinlog . It is going to track everything that potentially updates data. you can grep out whatever you need from that log easily.

    http://dev.mysql.com/doc/refman/5.0/en/mysqlbinlog.html

    http://dev.mysql.com/doc/refman/5.0/en/binary-log.html

提交回复
热议问题