참고 : https://mine-it-record.tistory.com/205
[SPRING] log4j2.xml 설정 (feat. level)
스프링 로그를 보이지 않게 끄는 방법에 대해 알아보자 log를 설정할 때 level 이 쓰여있는 것이 보이는데 이 역시 단계가 존재한다. 높은 등급에서 낮은 등급으로의 6개의 로그 레벨을 가지며 지정한 레벨 등급..
mine-it-record.tistory.com
https://www.callicoder.com/spring-boot-log4j-2-example/
How to use Log4j 2 with Spring Boot
Learn how to integrate and configure Log4j 2 in Spring Boot applications with RollingFile, SMTP appenders, and Async Loggers
www.callicoder.com
기능
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>