fixed query logging