How to log the queries executed by Spring Data MongoDB?

孤街醉人 提交于 2021-02-04 05:42:09

问题


Is there a way to find the query that was run against the database in spring data mongodb?

I know this is possible in case of JPA. So was just wondering if there was something similar in Spring data MongoDB?


回答1:


The easiest way is to set the log level to DEBUG for org.springframework.data.mongodb.




回答2:


logging:
  level:
    org.springframework.data.mongodb.core.MongoTemplate: DEBUG

To clarify Oliver's answer add that to the application.yml file or properties file.



来源:https://stackoverflow.com/questions/49143140/how-to-log-the-queries-executed-by-spring-data-mongodb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!