Move logging for certain SQL queries