spring mybatis log 설정

스프링 설정을 application.property 파일이 아닌 application.yml 을 사용 하는 구조에서 로그 자료 이다.

=====================================
= application.yml
=====================================
logging:
  level:
    org:
      mybatis: DEBUG
    kr:
      co:
         company:
           project: TRACE

위 설정으로 로그를 보면 보이긴 하지만 PREPARE STATEMENT 와 컬럼이 각각 출력 되어
디버깅에 무지 않좋다.

<!-- https://mvnrepository.com/artifact/org.lazyluke/log4jdbc-remix -->
<dependency>
    <groupId>org.lazyluke</groupId>
    <artifactId>log4jdbc-remix</artifactId>
    <version>0.2.7</version>
</dependency>


http://addio3305.tistory.com/66 설명에는 context-datasource.xml을 수정이 기술 되어 있다.

http://www.programcreek.com/java-api-examples/index.php?api=net.sf.log4jdbc.Log4jdbcProxyDataSource 프로그램 방식으로 dataSource 생성


@Bean public DataSource dataSource(){
  Log4JdbcCustomFormatter formatter=new Log4JdbcCustomFormatter();
  formatter.setLoggingType(LoggingType.MULTI_LINE);
  formatter.setSqlPrefix("SQL:\r");
  EmbeddedDatabase embeddedDatabase=new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.H2).build();
  Log4jdbcProxyDataSource dataSource=new Log4jdbcProxyDataSource(embeddedDatabase);
  dataSource.setLogFormatter(formatter);
  return dataSource;
}

쓸려고 다 찾았으나.. 

log4jdbc-log4j2 요거 쓰라는 이야기

https://code.google.com/archive/p/log4jdbc-log4j2/downloads


댓글