public DBCursor findLogs(String projectName, LogQuery logQuery, int max) throws ParseException {
Project project = projectService.findProject(projectName);
MongoTemplate template = project.fetchMongoTemplate();
Query query = new BasicQuery(logQuery.toQuery());
query.limit(max);
query.sort().on("timestamp", Order.DESCENDING);
logger.debug("find logs from {} by query {} by sort {}", new Object[]{project.getLogCollection(), query.getQueryObject(), query.getSortObject()});
DBCursor cursor = template.getCollection(project.getLogCollection()).find(query.getQueryObject()).sort(query.getSortObject()).limit(max);
return cursor;