1. 의존성 추가
- pom.xml
<dependency>
<groupId>org.bgee.log4jdbc-log4j2</groupId>
<artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
<version>1.16</version>
</dependency>
2. 설정 파일 추가
- log4jdbc.log4j2.properties ( /resources/log4jdbc.log4j2.properties )
log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
log4jdbc.dump.sql.maxlinelength=0
log4jdbc.auto.load.popular.drivers=false
3. datasource 설정 변경
- application.properties
# 수정전
spring.datasource.hikari.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.hikari.jdbc-url=jdbc:mariadb://localhost:3306/mall
# 수정후
spring.datasource.hikari.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.hikari.jdbc-url=jdbc:log4jdbc:mariadb://localhost:3306/mall
4. Logging 설정 추가
- application.properties
logging.group.jdbc-viewer=jdbc.sqltiming,jdbc.resultsettable
logging.group.jdbc-off=jdbc,jdbc.connection,jdbc.sqlonly,jdbc.audit,jdbc.resultset,jdbc.connection
logging.level.jdbc-viewer=info
logging.level.jdbc-off=off
'[Java] > [Spring]' 카테고리의 다른 글
[SpringBoot] Redis 설정 ( Cache 사용 ) (0) | 2024.09.20 |
---|---|
[SpringBoot] Redis 설정 ( RedisTemplate 사용 ) (0) | 2024.09.12 |
[SpringBoot] Logback 설정 (0) | 2024.08.27 |
[SpringBoot] Jasypt 설정( 프로퍼티 암호화 ) (0) | 2024.08.26 |
[SpringBoot] Thymeleaf 설정 (0) | 2024.08.26 |