Spring boot集成MongoDB在控制台输出执行日志

这里用的是logback日志,所以在logback.xml配置文件中加入以下内容:

运行效果如下:

2018-07-25 09:27:51.074-|-DEBUG-|-http-nio-8760-exec-4-|-org.springframework.data.mongodb.core.MongoDbUtils[122]-|-Getting Mongo Database name=[xxx]
2018-07-25 09:27:51.080-|-DEBUG-|-http-nio-8760-exec-4-|-org.springframework.data.mongodb.core.MongoTemplate[1783]-|-find using query: { "mid" : "s1015" , "et" : { "$gte" : { "$date" : "2018-07-25T01:27:51.079Z"}} , "ct" : { "$lte" : { "$date" : "2018-07-25T01:27:51.079Z"}} , "lock" : { "$gt" : 0}} fields: { "lock" : 1 , "aid" : 1} for class: class com.xxxx.xxxx.model.xxx.xxx in collection: xxxx
2018-07-25 09:27:51.081-|-DEBUG-|-http-nio-8760-exec-4-|-org.springframework.data.mongodb.core.MongoDbUtils[122]-|-Getting Mongo Database name=[zs_ot]
2018-07-25 09:27:51.091-|-DEBUG-|-http-nio-8760-exec-4-|-org.springframework.data.mongodb.core.MongoTemplate[1732]-|-findOne using query: { "id" : "s54"} fields: null for class: class com.xxxx.xxxx.model.xxx.xxx in collection: xxx
2018-07-25 09:27:51.091-|-DEBUG-|-http-nio-8760-exec-4-|-org.springframework.data.mongodb.core.MongoDbUtils[122]-|-Getting Mongo Database name=[xxx]
2018-07-25 09:27:51.091-|-DEBUG-|-http-nio-8760-exec-4-|-org.springframework.data.mongodb.core.MongoTemplate[2194]-|-findOne using query: { "_id" : "s54"} in db.collection: xx.xxx
2018-07-25 09:27:51.108-|-DEBUG-|-http-nio-8760-exec-4-|-org.springframework.data.mongodb.core.MongoTemplate[1732]-|-findOne using query: { "id" : "s64"} fields: null for class: class com.xxxx.xxxx.model.xxx.xxx in collection: xxx
2018-07-25 09:27:51.108-|-DEBUG-|-http-nio-8760-exec-4-|-org.springframework.data.mongodb.core.MongoDbUtils[122]-|-Getting Mongo Database name=[xxx]
2018-07-25 09:27:51.108-|-DEBUG-|-http-nio-8760-exec-4-|-org.springframework.data.mongodb.core.MongoTemplate[2194]-|-findOne using query: { "_id" : "s64"} in db.collection: xxx.xxxx

 

你可能感兴趣的:(MongoDB)