One of the ways to improve your application performance in Couchbase is to create indexes for common queries. However, when you are working with Spring Data using its standard DSL, the generated query is not very clear, which makes a little bit more difficult to create the right index to it.

This problem can be easily solved by enabling DEBUG log level in the class AbstractN1qlBasedQuery, it will print the generated N1QL query in the log, a behavior very similar to enabling the attribute show_sql in Hibernate.  Here is how you can set this configuration in your application.yml

You can also enable it via logback  by simply adding it as a dependency:

And then, add the logback.xml configuration file in your resources folder:

When you run your application again, the generated N1QL queries will be printed in the logs.


If you have any questions, ping me at @deniswsrosa




Posted by Denis Rosa, Developer Advocate, Couchbase

Denis Rosa is a Developer Advocate for Couchbase and lives in Munich - Germany. He has a solid experience as a software engineer and speaks fluently Java, Python, Scala and Javascript. Denis likes to write about search, Big Data, AI, Microservices and everything else that would help developers to make a beautiful, faster, stable and scalable app.


  1. Does this work with SpringBoot 2.4 with springdata-couchbase 4.1.1?I couldn’t enable logging for repository queries with below logback-spring.xml?

    %d{HH:mm:ss} [%thread] %-5level %logger{36} – %msg%n

    1. %d{HH:mm:ss} [%thread] %-5level %logger{36} – %msg%n

      1. Seems comment can neither be edited nor deleted.logback xml is distorted.But its the same as your example

    2. Denis Rosa, Developer Advocate, Couchbase January 13, 2021 at 11:34 am

      Hi! please use the package from Spring Data 4 onwards

Leave a reply