Add query logging