logging sql query