[JPA] 로그 쿼리 , 파라미터 설정

hi·2023년 1월 9일
0

application.yml

Spring:
  jpa:
    properties:
      hibernate:
      	show_sql: true
        format_sql: true
        use_sql_comments: true
        
logging.level:
  org.hibernate.SQL: debug
  org.hibernate.type: trace
  • show_sql: true System.out 에 하이버네이트 실행 SQL 출력
  • org.hibernate.SQL: debug logger를 통해 하이버네이트 실행 SQL 출력
  • format_sql: true 쿼리가 세로로 나옴

  • org.hibernate.type: trace 파라미터 나옴 (운영시 꼭 성능 테스트)


build.gradle

implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.7'
  • 쿼리에 파라미터 추가되어 나옴
  • 운영 시스템에서는 성능 확인하고 사용

스프링 부트 3.0 추가 설정 필요

  1. org.springframework.boot.autoconfigure.AutoConfiguration.imports 파일 추가

폴더명 src/resources/META-INF/spring/
파일명 org.springframework.boot.autoconfigure.AutoConfiguration.imports

com.github.gavlyukovskiy.boot.jdbc.decorator.DataSourceDecoratorAutoConfigurati
on
  1. spy.properties 파일 추가

src/resources/spy.properties

appender=com.p6spy.engine.spy.appender.Slf4JLogger

0개의 댓글