In my previous post, Capturing Erroneous Queries with MySQL Proxy, I showed how to capture erroneous queries, along with relevant information, that one could not effectively obtain from the MySQL general query log. However, in that post, I simply output the information to the terminal. Therefore, in this example, I want to show how to write this information to a proxy log file.
To change this to log to a log file does not require too many changes, and so this is a useful example on how to log any proxy-related information to a log file.
- I perform a check for an existing log file (at least using
the variable of name “log_file”), and then assign log_file to the
location of where I want the log file to reside (at the beginning
of the lua script).
if (log_file == nil) then log_file = "C:/Program Files/MySQL/mysql-proxy-0.7.2/proxy.log" end …