How to show sql Queries in console in springboot azure (Springboot + Azure Cosmos)

1.8k Views Asked by At

i am using SpringBoot with azurecosmos db

i want to see the query for below repository code.

findByFirstNameAndLastName(String firstName,String lastName);

3

There are 3 best solutions below

0
On BEST ANSWER

For me adding following configuration to application.yaml worked.

logging:
  config: classpath:logback-local-spring.xml
  level:
    com.azure.cosmos.implementation.SqlQuerySpecLogger: debug
2
On

You can try adding the below lines inside application.properties to get all the query generated in console

spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
logging.level.org.hibernate.SQL = DEBUG
logging.level.org.hibernate.type = TRACE
logging.level.org.springframework.web = DEBUG
0
On

You can use also logback. Here is one example:

<configuration>
<include resource="/org/springframework/boot/logging/logback/base.xml"/>
<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="info">
    <appender-ref ref="STDOUT"/>
</root>
<logger name="com.azure.cosmos" level="error"/>
<logger name="org.springframework" level="error"/>
<logger name="io.netty" level="error"/>
<logger name="com.azure.cosmos.implementation.SqlQuerySpecLogger" level="DEBUG"/>