2

In my Spring-Boot app we have a Spring-Data repository connection to the Couchbase server.

I know that when connecting to SQL server, one can see the actual queries sent to the DB by adding to the property file line such as this one (As mentioned here):

logging.level.org.hibernate.SQL=DEBUG

What should be the way to do it when using Couchbase?

riorio
  • 6,500
  • 7
  • 47
  • 100

4 Answers4

2

Add logback as your dependency

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.3</version>
    </dependency>

and add the file logback.xml to your resources folder:

<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
</appender>

<root level="debug">
    <appender-ref ref="STDOUT" />
</root>

If I remember it correctly, you can enable dubug level only in the class that prints the query with the following configuration:

<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
        <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
</appender>

<logger name="org.springframework.data.couchbase.repository.query" level="debug" />

<root level="info">
    <appender-ref ref="STDOUT" />
</root>

deniswsrosa
  • 2,421
  • 1
  • 17
  • 25
1

Following deniswasrosa's answer I was able to see the queries just by adding this to the yml file:

logging:
   level:  
     org.springframework.data.couchbase.repository.query: DEBUG

I had no need to add the dependency.

riorio
  • 6,500
  • 7
  • 47
  • 100
0

In my case I'm using Kotlin and spring-boot-starter-data-couchbase dependency, what it works for me on properties file was to use:

logging.level.org.springframework.data=DEBUG

mauronet
  • 850
  • 12
  • 17
0

I'm using spring data Couchbase 4.4.1 and had to use the below. Did not spend much time to find a better answer though. It workes for my porposes

<logger name="org.springframework.data.couchbase.core" level="trace" />
antonkronaj
  • 1,237
  • 12
  • 13