Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Data Mongodb: How to Dump Raw Query/Commands generated through QueryDsl?

I'm using Spring Data's Querydsl integration to execute my queries using predicates.

findAll(predicate, pageable)

Is there a way to dump the actual raw queries/commands that get executed?

I have also looked at the answer to this question and it wasn't working for me.. Configure logging for the MongoDB Java driver

--Update-- I've managed to get the logging working by adding logging.level.org.mongodb.driver=DEBUG in application.properties (not log4j.properties)

But still, I can't see the raw query that's being performed:

2016-03-23 21:50:56 DEBUG query:56 - Query completed 2016-03-23 21:50:56 DEBUG query:56 - Sending query of namespace testdb.reservation on connection [connectionId{localValue:4, serverValue:42631}] to server ds046785.mongolab.com:39186

like image 662
user1955934 Avatar asked Mar 13 '16 04:03

user1955934


1 Answers

Enable the profiler by setting the profile value using the following command in the mongo shell:

db.setProfilingLevel(2)

output of the profiler can be viewed using this command:

db.system.profile.find( { millis : { $gt : 100 } } )

This command displays all operations longer than 100 milliseconds

like image 139
vembutech Avatar answered Oct 04 '22 09:10

vembutech