JAVA
[Spring Boot] p6spy - 외부 라이브러리 사용하기
milna
2023. 10. 25. 04:39
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
외부 라이브러리
사용할 라이브러리를 build.gradle에 추가한다.
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.8.0'
p6spy
SQL 쿼리 파라미터를 로그로 남기기 위해 p6spy 라이브러리를 추가하였다.
2022-06-20 16:00:49.873 INFO 10324 --- [ main] p6spy : #1655708449873 | took 0ms | statement | connection 3| url jdbc:h2:tcp://localhost/~/jpashop
insert into member (username, id) values (?, ?)
insert into member (username, id) values ('memberA', 1);
2022-06-20 16:00:49.876 INFO 10324 --- [ main] p6spy : #1655708449876 | took 0ms | commit | connection 3| url jdbc:h2:tcp://localhost/~/jpashop
테스트를 실행하면 SQL 실행 파라미터가 로그로 남는다.
* 외부 라이브러리는 시스템 자원을 사용하므로 개발 단계에서는 사용해도 괜찮지만,
운영 배포 시에 성능이 저하될 수 있기 때문에 성능 테스트를 하고 사용하는 것이 좋다.