PDA

View Full Version : How to Log Query String for Mongo



Dave Rogers
Mar 25th, 2011, 12:19 PM
Hey There,

I'm trying to see why my query is returning no results... and would like to see the exact query executed. I tried to get this to log by adding

log4j.category.org.springframework.data.document=T RACE

to my log4j.properties i get SOME extra logging but not the query.

Is there a way to list the query that is being executed?

Thanks!
Dave

Oliver Gierke
Mar 29th, 2011, 01:44 PM
Do you refer to the repositories? Actually, MongoQueryCreator logs the query it creates into DEBUG level. If you'd like to see more logging output inside MongoTemplate feel free to open a JIRA.

Regards,
Ollie

trisberg
Apr 6th, 2011, 07:40 PM
I just added some debug logging to the MongoTemplate's find methods. So if you enable DEBUG for org.springframework.data.document.mongodb you should see the query being used.

Dave Rogers
Apr 7th, 2011, 03:23 PM
Thanks, that helps a lot. I can see the template queries now. -D