Source:
<code>public long find(CRUDOperationContext ctx, DBCollection coll, DBObject mongoQuery, DBObject mongoProjection, DBObject mongoSort, Long from, Long to) { LOGGER.debug("Submitting query {}",mongoQuery); long executionTime=System.currentTimeMillis(); DBCursor cursor = new FindCommand(coll, mongoQuery, mongoProjection).executeAndUnwrap(); executionTime=System.currentTimeMillis()-executionTime; LOGGER.debug("Query evaluated"); if (mongoSort != null) { cursor = cursor.sort(mongoSort); LOGGER.debug("Result set sorted"); } int size = cursor.size(); long ret = size; LOGGER.debug("Applying limits: - {}", from, to); if (from != null) { cursor.skip(from.intValue()); if(to!=null && from>to) cursor.skip(size); } if (to != null) { if(to >= 0) cursor.limit(to.intValue() - (from == null ? 0 : from.intValue()) + 1); else if(to < 0) cursor.skip(size); } LOGGER.debug("Retrieving results"); long retrievalTime=System.currentTimeMillis(); List<DBObject> mongoResults = cursor.toArray(); retrievalTime=System.currentTimeMillis()-retrievalTime; LOGGER.debug("Retrieved results", mongoResults.size()); List<JsonDoc> jsonDocs = translator.toJson(mongoResults); if(RESULTSET_LOGGER.isDebugEnabled()&&(executionTime>100 || retrievalTime>100)) { <START> RESULTSET_LOGGER.debug("Execution time:{}, Retrieval time:{}, Resultset size: {}, Data size:{}, Query:{}", <END> executionTime,retrievalTime,mongoResults.size(),Translator.size(jsonDocs),mongoQuery); } ctx.addDocuments(jsonDocs); for (DocCtx doc : ctx.getDocuments()) { doc.setCRUDOperationPerformed(CRUDOperation.FIND); ctx.getFactory().getInterceptors().callInterceptors(InterceptPoint.POST_CRUD_FIND_DOC, ctx, doc); } LOGGER.debug("Translated DBObjects to json"); return ret; }</code><technical_language>log format splunk friendly, i.e. execution_time={}, retrieval_time={}...? way, if decide log this server.log (or other splunk indexed file), query conditions, sort, etc</technical_language>

Target:
public long find(CRUDOperationContext ctx, DBCollection coll, DBObject mongoQuery, DBObject mongoProjection, DBObject mongoSort, Long from, Long to) { LOGGER.debug("Submitting query {}",mongoQuery); long executionTime=System.currentTimeMillis(); DBCursor cursor = new FindCommand(coll, mongoQuery, mongoProjection).executeAndUnwrap(); executionTime=System.currentTimeMillis()-executionTime; LOGGER.debug("Query evaluated"); if (mongoSort != null) { cursor = cursor.sort(mongoSort); LOGGER.debug("Result set sorted"); } int size = cursor.size(); long ret = size; LOGGER.debug("Applying limits: - {}", from, to); if (from != null) { cursor.skip(from.intValue()); if(to!=null && from>to) cursor.skip(size); } if (to != null) { if(to >= 0) cursor.limit(to.intValue() - (from == null ? 0 : from.intValue()) + 1); else if(to < 0) cursor.skip(size); } LOGGER.debug("Retrieving results"); long retrievalTime=System.currentTimeMillis(); List<DBObject> mongoResults = cursor.toArray(); retrievalTime=System.currentTimeMillis()-retrievalTime; LOGGER.debug("Retrieved results", mongoResults.size()); List<JsonDoc> jsonDocs = translator.toJson(mongoResults); if(RESULTSET_LOGGER.isDebugEnabled()&&(executionTime>100 || retrievalTime>100)) { RESULTSET_LOGGER.debug("execution_time={}, retrieval_time={}, resultset_size={}, data_size={}, query={}", executionTime,retrievalTime,mongoResults.size(),Translator.size(jsonDocs),mongoQuery); } ctx.addDocuments(jsonDocs); for (DocCtx doc : ctx.getDocuments()) { doc.setCRUDOperationPerformed(CRUDOperation.FIND); ctx.getFactory().getInterceptors().callInterceptors(InterceptPoint.POST_CRUD_FIND_DOC, ctx, doc); } LOGGER.debug("Translated DBObjects to json"); return ret; }