로거를 통한 쿼리문 로깅을 위해 logging.level.org.hibernate.sql: debug 를 application.yaml에 작성해주었으나 제대로 작동하지 않는 것을 발견하였다.
이 문제는 logging.level.org.hibernate.SQL: debug 와 같이 'sql'을 'SQL'로 작성해주면 해결된다.
logging.level.org.hibernate.sql
logging:
level:
org.hibernate.sql: debug
org.hibernate.type: trace
🔼실행결과 쿼리문 확인 불가
logging:
level:
org.hibernate.SQL: debug
org.hibernate.type: trace
🔼실행결과 정상적으로 출력된 쿼리문 확인
org.hibernate.SQL이 아닌 debug org.hibernate.sql을 작성했던 것이 문제였다.

이걸 선택해야했었다.(애초에 대문자로 작성하자.)

logging.level.org.hibernate.SQL: debug

: logging.level.* 형식을 통해 org.hibernate.SQL에 대한 로깅 레벨을 debug로 설정
spring.jpa.properties.hibernate.show_sql 설정과 비교
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL8Dialect
show_sql: true #A
format_sql: true
use_sql_comments: true
hbm2ddl:
auto: create
default_batch_fetch_size: 1000
logging:
level:
org.hibernate.sql: debug #B
spring.jpa.properties.hibernate.show_sql: true 옵션을 A, logging.level.org.hibernate.sql: debug 옵션을 B라고 하자.
A는 하이버네이트 실행 SQL문을 시스템 출력하고 B는 logger를 통해 출력한다. 따라서 spring.jpa.properties.hibernate.show_sql: true은 끄고 logging.level.org.hibernate.sql: debug 옵션을 사용하는 것이 좋다.
reference
https://sematext.com/blog/logging-levels/
Logging Levels: What They Are & How to Choose Them - Sematext
Learn about the most common log levels and how they work. Best practices on when and how to use them to control log output and filter alerts.
sematext.com
'트러블슈팅' 카테고리의 다른 글
[Redis Error] Unable to send PING command over channel (0) | 2024.10.22 |
---|---|
springboot Could not move temporary workspace 오류 (0) | 2024.05.01 |
Git "There is no tracking information for the current branch. Please specify which branch you want to merge with. "오류 (0) | 2024.01.09 |
git push author 변경 (0) | 2023.09.04 |
400 에러 - 필드가 하나인 DTO의 기본 생성자 부재... (0) | 2023.08.22 |