본문 바로가기
개발/Spring Boot

10.SQL Log 설정

by 카리3 2021. 2. 12.

1.pom.xml 설정

		<!-- https://mvnrepository.com/artifact/org.bgee.log4jdbc-log4j2/log4jdbc-log4j2-jdbc4.1 -->
		<dependency>
		    <groupId>org.bgee.log4jdbc-log4j2</groupId>
		    <artifactId>log4jdbc-log4j2-jdbc4.1</artifactId>
		    <version>1.16</version>
		</dependency>

2. application.properties 설정

spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.url: jdbc:log4jdbc:mysql://127.0.0.1:3306/SECKIMDB?useSSL=false&serverTimezone=Asia/Seoul
spring.datasource.username=SECKIM
spring.datasource.password=1234
mybatis.mapper-locations=classpath:mapper/mapping*.xml

3.log4jdbc.log4j2.properties 설정

log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
log4jdbc.dump.sql.maxlinelength=0

log4jdbc.auto.load.popular.drivers = false

4.log4j2.xml

<logger name="jdbc" level="OFF"/>  
<logger name="jdbc.sqlonly" level="OFF"/>
<logger name="jdbc.sqltiming" level="INFO"/>
<logger name="jdbc.audit" level="OFF"/>
<logger name="jdbc.resultset" level="OFF"/>
<logger name="jdbc.resultsettable" level="DEBUG"/>
<logger name="jdbc.connection" level="OFF"/>

'개발 > Spring Boot' 카테고리의 다른 글

12.webjars 설정  (0) 2021.02.15
11.Tag Library  (0) 2021.02.15
9. Annotation 설정  (0) 2021.02.12
8. Spring Security 설정  (0) 2021.02.12
7.aop 설정  (0) 2021.02.11