Changed SQL logging to log final SQL instead of pre-substitution SQL