본문 바로가기

짤막 지식

[짤막 지식] 쿼리 파라미터 로그 남기기

 

 

콘솔창 보면 아래처럼 쿼리 공식만 찍히고, 그 안에 쿼리 파라미터가 ? 로만 남아있는 게 너무 불편하고 뭐라는지도 모르겠다싶다..

insert
into
	member
    	(username, id)
    values
    	(?, ?)

 

으!! 좀 답답해!!!!

 

 

해결방법 1.

application.yml 파일에서 로깅 레벨 아래에

org.hibernate.orm.jdbc.bind: trace로 적어주면 완성이다!

(기준 : 스프링부트 3.x)

 

 

 

해결 후 다시 서버를 돌려주면

이렇게 쿼리 파라미터를 콘솔에다가 찍어준다. 좋다~!

 

 

해결방법 2. 외부 라이브러리 spring-boot-data-source-decorator 활용

https://github.com/gavlyukovskiy/spring-boot-data-source-decorator

 

GitHub - gavlyukovskiy/spring-boot-data-source-decorator: Spring Boot integration with p6spy, datasource-proxy, flexy-pool and s

Spring Boot integration with p6spy, datasource-proxy, flexy-pool and spring-cloud-sleuth - GitHub - gavlyukovskiy/spring-boot-data-source-decorator: Spring Boot integration with p6spy, datasource-p...

github.com

implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.9.0'

 

 

추가 후 gradle refresh 하기

 

 

 

 

 

 

 

 

 

 

다시 메서드 실행하면은~

짜잔!!