Add query logging.