0

I am using salat library in play!framework to query data from MongoDB. I have troubles with some queries. So, I want to log (using logback in play!) to see how the actual queries that are generated by salat.

mmdc
  • 1,677
  • 3
  • 20
  • 32

3 Answers3

2

Salat is based on MongoDB Java driver so you can simply turn debugging level for the driver on. Here is how:

Configure logging for the MongoDB Java driver.

The disadvantage is that the format is slightly different than what you execute in Mongo shell.

Community
  • 1
  • 1
yǝsʞǝla
  • 16,272
  • 2
  • 44
  • 65
  • You need to check your logging configuration in Play for example. Java Mongo driver will log to your default logger which is probably set up by Play. That logger in turn will filter stuff based on its configuration. Please provide logback.xml or what have you + application.conf log related settings and whatever else affects the logging. – yǝsʞǝla Jan 16 '15 at 01:47
  • Check this for logging config settings: https://www.playframework.com/documentation/2.0/SettingsLogger – yǝsʞǝla Jan 16 '15 at 01:49
  • You can set `System.setProperty("DEBUG.MONGO", "true");` in code or through java cmd args with -D flag: `java -DDEBUG.MONGO=true` for example. Check in your code that you have that property properly set as well. – yǝsʞǝla Jan 16 '15 at 01:53
0

I worked around with this by converting MongoDBObject to JSON and then logging it using Logger.debug in play. So, it looks like this:

Logger.debug(com.mongodb.util.JSON.serialize([MongoDBObject here...]))

mmdc
  • 1,677
  • 3
  • 20
  • 32
0

Copy/paste following lines to your application.conf:

logger.root=DEBUG
logger.play=DEBUG
logger.application=DEBUG
Mon Calamari
  • 4,403
  • 3
  • 26
  • 44
  • it's seem the configurations for logging level of playframework itself. It does not apply for mongodb or salat. I used logger.com.mongodb=DEBUG does show some info, but they are not queries that I want. – mmdc Jan 15 '15 at 18:41
  • I use it to log queries to console from Hibernate or JOOQ. – Mon Calamari Jan 16 '15 at 08:33