1

I am using Couchbase SDK along with Spring boot 2.6.x version. I am using the spring spring-data-couchbase:jar:4.4.0 which in turn has com.couchbase.client:java-client:jar:3.3.0 dependency. The issue, is when trying to execute cluster.query() methods, I need to see what query is getting executed. I need to enable debug logs. However, I have tried configuring it under properties for logging.level for the package com.couchbase.client to DEBUG level, nothing is showing up. I tried the similar config in log4j.xml as well and no luck either. Does couchbase uses any wierd property or is it not reading the properties specified from either log4j or spring's properties?

You may ask if raw query is passed then why log specifically, but this is required if using parameterised queries and to debug it.

How does one enable logging for couchbase if using plain sdk methods under spring's context ?

Deekshith Anand
  • 2,175
  • 1
  • 21
  • 24
  • 1
    There is no log level in the Couchbase Java SDK that will log user queries, since generally this will be a very high/spammy amount of output. Your application will need to log that itself. – Graham Pople Nov 22 '22 at 16:38

2 Answers2

1

Can you enable couchbase specific properties of spring-data and not package within the application?

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

This should help ! It won't require any external dependency or logging solutions

Harsh
  • 812
  • 1
  • 10
  • 23
  • Similar article ! https://stackoverflow.com/questions/53373431/how-to-log-spring-data-queries-to-a-couchbase-database – Harsh Nov 22 '22 at 09:08
  • Thank you, but no luck for me. I am using raw sdk methods instead of sring data jpa, i tried above as well, but its not logging. – Deekshith Anand Nov 22 '22 at 09:22
0

For the cluster, add ServiceType.QUERY to captureTraffic...

env.ioConfig(it -> it.captureTraffic(ServiceType.QUERY))

and also set the log level for the com.couchbase category to TRACE

mn_test347
  • 354
  • 2
  • 6