public void logQuery(final SQLRequest request, final SQLResponse response) { final String user = SecurityContextHolder.getContext().getAuthentication().getName(); final Set<String> realizationNames = new HashSet<String>(); final Set<Long> cuboidIds = new HashSet<Long>(); float duration = response.getDuration() / (float) 1000; if (!response.isHitCache() && null != OLAPContext.getThreadLocalContexts()) { for (OLAPContext ctx : OLAPContext.getThreadLocalContexts()) { Cuboid cuboid = ctx.storageContext.getCuboid(); if (cuboid != null) { // Some queries do not involve cuboid, e.g. lookup table query cuboidIds.add(cuboid.getId()); } if (ctx.realization != null) { String realizationName = ctx.realization.getName(); realizationNames.add(realizationName); } } } int resultRowCount = 0; if (!response.getIsException() && response.getResults() != null) { resultRowCount = response.getResults().size(); } String newLine = System.getProperty("line.separator"); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(newLine); stringBuilder .append("==========================[QUERY]===============================") .append(newLine); stringBuilder.append("SQL: ").append(request.getSql()).append(newLine); stringBuilder.append("User: "******"Success: ") .append((null == response.getExceptionMessage())) .append(newLine); stringBuilder.append("Duration: ").append(duration).append(newLine); stringBuilder.append("Project: ").append(request.getProject()).append(newLine); stringBuilder.append("Realization Names: ").append(realizationNames).append(newLine); stringBuilder.append("Cuboid Ids: ").append(cuboidIds).append(newLine); stringBuilder.append("Total scan count: ").append(response.getTotalScanCount()).append(newLine); stringBuilder.append("Result row count: ").append(resultRowCount).append(newLine); stringBuilder.append("Accept Partial: ").append(request.isAcceptPartial()).append(newLine); stringBuilder.append("Is Partial Result: ").append(response.isPartial()).append(newLine); stringBuilder.append("Hit Cache: ").append(response.isHitCache()).append(newLine); stringBuilder.append("Message: ").append(response.getExceptionMessage()).append(newLine); stringBuilder .append("==========================[QUERY]===============================") .append(newLine); logger.info(stringBuilder.toString()); }