如何在控制台或文件中记录 spring data 生成的 solr 查询

sak*_*ute 3 java spring-data-solr spring-boot

如何在控制台或文件中记录 spring data 生成的 solr 查询。我正在使用 Spring Boot 版本 1.4.3.RELEASE 中的 spring-data-solr 版本 2.0.6.RELEASE。

我正在尝试在文件或控制台中记录语句,因为我们可以在 spring-data-jpa 中为 sql 语句执行此操作。

Chr*_*obl 10

SolrTemplate执行查询时记录创建的查询字符串。启用日志记录,例如。通过logback.xml添加

<logger name="org.springframework.data.solr.core.SolrTemplate" level="DEBUG"/>
Run Code Online (Sandbox Code Playgroud)

这应该给你类似的东西:

2017-10-17 08:09:45,451 DEBUG o.s.d.solr.core.SolrTemplate: 504 - Executing query 'q={!join+from%3Dmanu_id_s+to%3Did}text:ipod' against solr.
2017-10-17 08:09:46,148 DEBUG o.s.d.solr.core.SolrTemplate: 504 - Executing query 'q=*:*&facet=true&facet.mincount=1&facet.limit=5&facet.field=name&facet.field=cat&facet.prefix=lan&f.name.facet.prefix=spr' against solr.
Run Code Online (Sandbox Code Playgroud)

如果您在日志中丢失信息,请随时在错误跟踪器中打开增强请求。