Added a query log to support debugging