참고 : https://mine-it-record.tistory.com/205
https://www.callicoder.com/spring-boot-log4j-2-example/
기능
SQL Query로그 출력
그래들
implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4:1.16'
설정
main>resources>log4jdbc.log4j2.properties
log4jdbc.splylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
main>resources>application.properties, log출력을 원하는 DB설정 부분에 대해서...
#spring.datasource.url=jdbc:oracle:thin:@172.16.00.00:1521:xe
spring.datasource.url=jdbc:log4jdbc:oracle:thin:@172.16.00.00:1521:xe
#spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
테스트용 로그레벨 설정
test>resources>log4j.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Appenders>
<Console name="console" target="SYSTEM_OUT">
<PatternLayout pattern="%d %5p [%c] %m%n"/>
</Console>
</Appenders>
<Loggers>
<!-- 3rdparty Loggers -->
<Logger name="jdbc.audit" level="warn">
</Logger>
<Logger name="jdbc.resultset" level="warn">
</Logger>
<Logger name="jdbc.connection" level="warn">
</Logger>
<!-- Root Logger -->
<Root level="info">
<AppenderRef ref="console"/>
</Root>
</Loggers>
</Configuration>