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?

4 Answers 4

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>

Sign up to request clarification or add additional context in comments.

Comments

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.

1 Comment

Thanks, I will write a post on Couchbase's blog about that to document this whole thing.
1

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

Comments

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" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.