-
[Spring Boot] REST API 만들기(4) - Log4jdbc 설정Spring Boot/2.4.x - REST API 만들기 2020. 5. 5. 17:34반응형
기본적으로 스프링 부트는 Java Util Logging, Log4J2 and Logback 기능을 지원하여 실행된 SQL문을 확인할 수 있지만, 파라미터가 바인드되지 않고 물음표로 출력되거나, 탭이나 개행문자가 적용되지 않아 가독성이 떨어지기 때문에 log4jdbc 설정이 필요합니다.
1. pom.xml 의존성 추가pom.xml에 log4jdbc-log4j2을 사용하기 위해 의존성을 추가하세요.
pom.xml
더보기123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.4.8</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.api</groupId><artifactId>board</artifactId><version>0.0.1-SNAPSHOT</version><name>board</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-configuration-processor --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional></dependency><!-- https://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter --><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.4</version></dependency><!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId></dependency><!-- 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></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>cs 2. application.properties 수정
DB 설정 정보 중 spring.datasource.hikari.driver-class-name, spring.datasource.hikari.jdbc-url 부분을 변경하세요.
application.properties
더보기1234567891011121314# datasource 설정spring.datasource.hikari.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpyspring.datasource.hikari.jdbc-url=jdbc:log4jdbc:mysql://localhost:3306/board?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTCspring.datasource.hikari.username=boardspring.datasource.hikari.password=password1!# root 로깅 레벨 설정logging.level.root=info# 패키지 단위로 로깅 레벨 설정logging.level.com.api.board=infologging.level.com.api.board.controller=debug# profiles 설정spring.profiles.active=localcs 3. log4jdbc.log4j2.properties 파일 추가
src/main/resources 폴더에 log4jdbc.log4j2.properties를 추가한 후 log4jdbc에 대한 내용을 설정하세요. maxlinelength는 SQL문을 최대 몇 라인까지 출력할 것인가를 결정합니다. 0으로 설정하면 라인에 제한 없이 실행된 SQL문을 출력하고 설정하지 않으면 한줄로 출력됩니다.
log4jdbc.log4j2.properties
더보기12log4jdbc.spylogdelegator.name=net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegatorlog4jdbc.dump.sql.maxlinelength=0cs 4. Console에서 로그 확인
더보기1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] o.s.web.servlet.DispatcherServlet - GET "/board", parameters={}2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to com.api.board.controller.BoardController#getBoardList()2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3bd280a3] was not registered for synchronization because synchronization is not active2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. Connection.isValid(5) returned true com.zaxxer.hikari.pool.PoolBase.isConnectionAlive(PoolBase.java:161)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. Connection.getAutoCommit() returned true com.zaxxer.hikari.pool.HikariProxyConnection.getAutoCommit(HikariProxyConnection.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] o.m.s.t.SpringManagedTransaction - JDBC Connection [HikariProxyConnection@890595753 wrapping net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@71693c60] will not be managed by Spring2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] c.a.b.m.BoardMapper.getBoardList - ==> Preparing: SELECT * FROM ( SELECT BOARD_SEQ , BOARD_RE_REF , BOARD_RE_LEV , BOARD_RE_SEQ , BOARD_WRITER , BOARD_SUBJECT , BOARD_CONTENT , BOARD_HITS , DEL_YN , INS_USER_ID , CAST( DATE_FORMAT( INS_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS INS_DATE , UPD_USER_ID , CAST( DATE_FORMAT( UPD_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS UPD_DATE FROM BOARD.TB_BOARD ORDER BY BOARD_RE_REF DESC, BOARD_RE_SEQ ASC ) T12020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. PreparedStatement.new PreparedStatement returned com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:337)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. Connection.prepareStatement(SELECT *FROM (SELECT BOARD_SEQ, BOARD_RE_REF, BOARD_RE_LEV, BOARD_RE_SEQ, BOARD_WRITER, BOARD_SUBJECT, BOARD_CONTENT, BOARD_HITS, DEL_YN, INS_USER_ID, CAST( DATE_FORMAT( INS_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS INS_DATE, UPD_USER_ID, CAST( DATE_FORMAT( UPD_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS UPD_DATEFROM BOARD.TB_BOARDORDER BY BOARD_RE_REF DESC, BOARD_RE_SEQ ASC) T1) returned net.sf.log4jdbc.sql.jdbcapi.PreparedStatementSpy@312aebd3 com.zaxxer.hikari.pool.ProxyConnection.prepareStatement(ProxyConnection.java:337)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] c.a.b.m.BoardMapper.getBoardList - ==> Parameters:2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.sqlonly - com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)1. SELECT *FROM (SELECT BOARD_SEQ, BOARD_RE_REF, BOARD_RE_LEV, BOARD_RE_SEQ, BOARD_WRITER, BOARD_SUBJECT, BOARD_CONTENT, BOARD_HITS, DEL_YN, INS_USER_ID, CAST( DATE_FORMAT( INS_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS INS_DATE, UPD_USER_ID, CAST( DATE_FORMAT( UPD_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS UPD_DATEFROM BOARD.TB_BOARDORDER BY BOARD_RE_REF DESC, BOARD_RE_SEQ ASC) T12020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.sqltiming - com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)1. SELECT *FROM (SELECT BOARD_SEQ, BOARD_RE_REF, BOARD_RE_LEV, BOARD_RE_SEQ, BOARD_WRITER, BOARD_SUBJECT, BOARD_CONTENT, BOARD_HITS, DEL_YN, INS_USER_ID, CAST( DATE_FORMAT( INS_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS INS_DATE, UPD_USER_ID, CAST( DATE_FORMAT( UPD_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS UPD_DATEFROM BOARD.TB_BOARDORDER BY BOARD_RE_REF DESC, BOARD_RE_SEQ ASC) T1{executed in 2 msec}2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. PreparedStatement.execute() returned true com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.new ResultSet returned com.zaxxer.hikari.pool.ProxyStatement.getResultSet(ProxyStatement.java:214)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. PreparedStatement.getResultSet() returned net.sf.log4jdbc.sql.jdbcapi.ResultSetSpy@74286392 com.zaxxer.hikari.pool.ProxyStatement.getResultSet(ProxyStatement.java:214)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getMetaData() returned com.mysql.cj.jdbc.result.ResultSetMetaData@5bd0222c - Field level information:com.mysql.cj.result.Field@451650de[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=BOARD_SEQ,originalColumnName=BOARD_SEQ,mysqlType=3(FIELD_TYPE_INT UNSIGNED),sqlType=4,flags= AUTO_INCREMENT PRIMARY_KEY UNSIGNED, charsetIndex=63, charsetName=ISO-8859-1]com.mysql.cj.result.Field@23044fdc[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=BOARD_RE_REF,originalColumnName=BOARD_RE_REF,mysqlType=3(FIELD_TYPE_INT),sqlType=4,flags=, charsetIndex=63, charsetName=ISO-8859-1]com.mysql.cj.result.Field@14079cdd[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=BOARD_RE_LEV,originalColumnName=BOARD_RE_LEV,mysqlType=3(FIELD_TYPE_INT),sqlType=4,flags=, charsetIndex=63, charsetName=ISO-8859-1]com.mysql.cj.result.Field@4e1c0d33[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=BOARD_RE_SEQ,originalColumnName=BOARD_RE_SEQ,mysqlType=3(FIELD_TYPE_INT),sqlType=4,flags=, charsetIndex=63, charsetName=ISO-8859-1]com.mysql.cj.result.Field@39fb348e[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=BOARD_WRITER,originalColumnName=BOARD_WRITER,mysqlType=253(FIELD_TYPE_VARCHAR),sqlType=12,flags=, charsetIndex=33, charsetName=UTF-8]com.mysql.cj.result.Field@3800e6c2[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=BOARD_SUBJECT,originalColumnName=BOARD_SUBJECT,mysqlType=253(FIELD_TYPE_VARCHAR),sqlType=12,flags=, charsetIndex=33, charsetName=UTF-8]com.mysql.cj.result.Field@1049646b[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=BOARD_CONTENT,originalColumnName=BOARD_CONTENT,mysqlType=253(FIELD_TYPE_VARCHAR),sqlType=12,flags=, charsetIndex=33, charsetName=UTF-8]com.mysql.cj.result.Field@3e9286c4[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=BOARD_HITS,originalColumnName=BOARD_HITS,mysqlType=3(FIELD_TYPE_INT UNSIGNED),sqlType=4,flags= UNSIGNED, charsetIndex=63, charsetName=ISO-8859-1]com.mysql.cj.result.Field@5e2d8adc[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=DEL_YN,originalColumnName=DEL_YN,mysqlType=253(FIELD_TYPE_VARCHAR),sqlType=12,flags=, charsetIndex=33, charsetName=UTF-8]com.mysql.cj.result.Field@61a4412d[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=INS_USER_ID,originalColumnName=INS_USER_ID,mysqlType=253(FIELD_TYPE_VARCHAR),sqlType=12,flags=, charsetIndex=33, charsetName=UTF-8]com.mysql.cj.result.Field@3a950b4e[dbName=null,tableName=T1,originalTableName=null,columnName=INS_DATE,originalColumnName=INS_DATE,mysqlType=253(FIELD_TYPE_VARCHAR),sqlType=12,flags=, charsetIndex=33, charsetName=UTF-8]com.mysql.cj.result.Field@101b1e7e[dbName=board,tableName=T1,originalTableName=TB_BOARD,columnName=UPD_USER_ID,originalColumnName=UPD_USER_ID,mysqlType=253(FIELD_TYPE_VARCHAR),sqlType=12,flags=, charsetIndex=33, charsetName=UTF-8]com.mysql.cj.result.Field@22521dcb[dbName=null,tableName=T1,originalTableName=null,columnName=UPD_DATE,originalColumnName=UPD_DATE,mysqlType=253(FIELD_TYPE_VARCHAR),sqlType=12,flags=, charsetIndex=33, charsetName=UTF-8] com.zaxxer.hikari.pool.HikariProxyResultSet.getMetaData(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getType() returned 1003 com.zaxxer.hikari.pool.HikariProxyResultSet.getType(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.isClosed() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.isClosed(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.next() returned true com.zaxxer.hikari.pool.HikariProxyResultSet.next(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_SEQ) returned 1 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_REF) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_LEV) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_SEQ) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_WRITER) returned 게시글 작성자1 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_SUBJECT) returned 게시글 제목1 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_CONTENT) returned 게시글 내용1 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_HITS) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(DEL_YN) returned N com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_USER_ID) returned TEST01 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_DATE) returned 2020-05-11 16:50:25 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_USER_ID) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_DATE) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.isClosed() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.isClosed(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.next() returned true com.zaxxer.hikari.pool.HikariProxyResultSet.next(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_SEQ) returned 2 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_REF) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_LEV) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_SEQ) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_WRITER) returned 게시글 작성자2 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_SUBJECT) returned 게시글 제목2 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_CONTENT) returned 게시글 내용2 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_HITS) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(DEL_YN) returned N com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_USER_ID) returned TEST02 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_DATE) returned 2020-05-11 16:50:26 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_USER_ID) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_DATE) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.isClosed() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.isClosed(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.next() returned true com.zaxxer.hikari.pool.HikariProxyResultSet.next(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_SEQ) returned 3 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_REF) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_LEV) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_SEQ) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_WRITER) returned 게시글 작성자3 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_SUBJECT) returned 게시글 제목3 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_CONTENT) returned 게시글 내용3 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_HITS) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(DEL_YN) returned N com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_USER_ID) returned TEST03 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_DATE) returned 2020-05-11 16:50:27 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_USER_ID) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_DATE) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.isClosed() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.isClosed(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.next() returned true com.zaxxer.hikari.pool.HikariProxyResultSet.next(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_SEQ) returned 4 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_REF) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_LEV) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_SEQ) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_WRITER) returned 게시글 작성자4 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_SUBJECT) returned 게시글 제목4 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_CONTENT) returned 게시글 내용4 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_HITS) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(DEL_YN) returned N com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_USER_ID) returned TEST04 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_DATE) returned 2020-05-11 16:50:29 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_USER_ID) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_DATE) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:57 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.isClosed() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.isClosed(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.next() returned true com.zaxxer.hikari.pool.HikariProxyResultSet.next(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_SEQ) returned 5 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_REF) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_LEV) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_RE_SEQ) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_WRITER) returned 게시글 작성자5 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_SUBJECT) returned 게시글 제목5 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(BOARD_CONTENT) returned 게시글 내용5 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getInt(BOARD_HITS) returned 0 com.zaxxer.hikari.pool.HikariProxyResultSet.getInt(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.wasNull() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.wasNull(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(DEL_YN) returned N com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_USER_ID) returned TEST05 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(INS_DATE) returned 2020-05-11 16:50:30 com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_USER_ID) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.getString(UPD_DATE) returned void com.zaxxer.hikari.pool.HikariProxyResultSet.getString(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.isClosed() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.isClosed(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [INFO ] jdbc.resultsettable -|----------|-------------|-------------|-------------|-------------|--------------|--------------|-----------|-------|------------|--------------------|------------|---------||board_seq |board_re_ref |board_re_lev |board_re_seq |board_writer |board_subject |board_content |board_hits |del_yn |ins_user_id |ins_date |upd_user_id |upd_date ||----------|-------------|-------------|-------------|-------------|--------------|--------------|-----------|-------|------------|--------------------|------------|---------||1 |0 |0 |0 |게시글 작성자1 |게시글 제목1 |게시글 내용1 |0 |N |TEST01 |2020-05-11 16:50:25 |null |null ||2 |0 |0 |0 |게시글 작성자2 |게시글 제목2 |게시글 내용2 |0 |N |TEST02 |2020-05-11 16:50:26 |null |null ||3 |0 |0 |0 |게시글 작성자3 |게시글 제목3 |게시글 내용3 |0 |N |TEST03 |2020-05-11 16:50:27 |null |null ||4 |0 |0 |0 |게시글 작성자4 |게시글 제목4 |게시글 내용4 |0 |N |TEST04 |2020-05-11 16:50:29 |null |null ||5 |0 |0 |0 |게시글 작성자5 |게시글 제목5 |게시글 내용5 |0 |N |TEST05 |2020-05-11 16:50:30 |null |null ||----------|-------------|-------------|-------------|-------------|--------------|--------------|-----------|-------|------------|--------------------|------------|---------|2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.next() returned false com.zaxxer.hikari.pool.HikariProxyResultSet.next(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] c.a.b.m.BoardMapper.getBoardList - <== Total: 52020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.resultset - 1. ResultSet.close() returned void com.zaxxer.hikari.pool.HikariProxyResultSet.close(HikariProxyResultSet.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. Connection.getMetaData() returned com.mysql.cj.jdbc.DatabaseMetaData@73e13597 com.zaxxer.hikari.pool.ProxyConnection.getMetaData(ProxyConnection.java:380)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. PreparedStatement.getMoreResults() returned false com.zaxxer.hikari.pool.HikariProxyPreparedStatement.getMoreResults(HikariProxyPreparedStatement.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. PreparedStatement.getUpdateCount() returned -1 com.zaxxer.hikari.pool.HikariProxyPreparedStatement.getUpdateCount(HikariProxyPreparedStatement.java:-1)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. PreparedStatement.close() returned com.zaxxer.hikari.pool.ProxyStatement.close(ProxyStatement.java:76)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@3bd280a3]2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] jdbc.audit - 1. Connection.clearWarnings() returned com.zaxxer.hikari.pool.ProxyConnection.close(ProxyConnection.java:267)2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Writing [[com.api.board.domain.Board@3b413d7b, com.api.board.domain.Board@9cfc39d, com.api.board.domain.Board (truncated)...]2020-05-12 16:06:58 [http-nio-8080-exec-3] [DEBUG] o.s.web.servlet.DispatcherServlet - Completed 200 OKcs 5. logback-spring.xml 설정 추가
Log4jdbc 옵션
jdbc.connection : Connection open, close 대한 로그를 출력합니다.
jdbc.sqlonly : SQL문만을 로그로 출력하며, PreparedStatement일 경우 관련된 argument 값으로 대체된 SQL문이 출력합니다.
jdbc.sqltiming : SQL문과 해당 SQL을 실행시키는데 수행된 시간 정보(milliseconds)를 출력합니다.
jdbc.audit : ResultSet을 제외한 모든 JDBC 호출 정보를 로그로 출력합니다.
jdbc.resultset : ResultSet을 포함한 모든 JDBC 호출 정보를 로그로 출력합니다.
jdbc.resultsettable : SQL 결과 조회된 데이터의 table을 로그로 출력합니다.
Log4jdbc 옵션 설정
logback-spring.xml에 log4jdbc 옵션을 설정해주세요.
logback-spring.xml
더보기123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110<?xml version="1.0" encoding="UTF-8"?><!-- 60초마다 설정 파일의 변경을 확인 하여 변경시 갱신 --><configuration scan="true" scanPeriod="60 seconds"><!--springProfile 태그를 사용하면 logback 설정 파일에서 복수개의 프로파일을 설정 --><springProfile name="local"><property resource="logback-local.properties" /></springProfile><springProfile name="dev"><property resource="logback-dev.properties" /></springProfile><!--Environment 내의 프로퍼티들을 개별적으로 설정 --><springProperty scope="context" name="LOG_LEVEL" source="logging.level.root"/><!-- log file path --><property name="LOG_PATH" value="${log.config.path}" /><!-- log file name --><property name="LOG_FILE_NAME" value="${log.config.filename}" /><!-- err log file name --><property name="ERR_LOG_FILE_NAME" value="err_log" /><!-- pattern --><property name="LOG_PATTERN" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] [%-5level] %logger{36} - %msg%n" /><!-- Console Appender --><appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"><encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"><pattern>${LOG_PATTERN}</pattern></encoder></appender><!-- File Appender --><appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> <!-- 파일경로 설정 --><file>${LOG_PATH}/${LOG_FILE_NAME}.log</file><!-- 출력패턴 설정 --><encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"><pattern>${LOG_PATTERN}</pattern></encoder><!-- Rolling 정책 --><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><!-- .gz,.zip 등을 넣으면 자동 일자별 로그파일 압축 --><fileNamePattern>${LOG_PATH}/${LOG_FILE_NAME}.%d{yyyy-MM-dd}_%i.log</fileNamePattern><timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><!-- 파일당 최고 용량 kb, mb, gb --><maxFileSize>10MB</maxFileSize></timeBasedFileNamingAndTriggeringPolicy><!-- 일자별 로그파일 최대 보관주기(~일), 해당 설정일 이상된 파일은 자동으로 제거 --><maxHistory>30</maxHistory><!--<MinIndex>1</MinIndex><MaxIndex>10</MaxIndex> --></rollingPolicy></appender><!-- 에러의 경우 파일에 로그 처리 --><appender name="Error" class="ch.qos.logback.core.rolling.RollingFileAppender"><filter class="ch.qos.logback.classic.filter.LevelFilter"><level>error</level><onMatch>ACCEPT</onMatch><onMismatch>DENY</onMismatch></filter><file>${LOG_PATH}/${ERR_LOG_FILE_NAME}.log</file><encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"><pattern>${LOG_PATTERN}</pattern></encoder><!-- Rolling 정책 --><rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"><!-- .gz,.zip 등을 넣으면 자동 일자별 로그파일 압축 --><fileNamePattern>${LOG_PATH}/${ERR_LOG_FILE_NAME}.%d{yyyy-MM-dd}_%i.log</fileNamePattern><timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"><!-- 파일당 최고 용량 kb, mb, gb --><maxFileSize>10MB</maxFileSize></timeBasedFileNamingAndTriggeringPolicy><!-- 일자별 로그파일 최대 보관주기(~일), 해당 설정일 이상된 파일은 자동으로 제거 --><maxHistory>60</maxHistory></rollingPolicy></appender><!-- root레벨 설정 --><root level="${LOG_LEVEL}"><appender-ref ref="CONSOLE" /><appender-ref ref="FILE" /><appender-ref ref="Error" /></root><!-- 특정패키지 로깅레벨 설정 --><logger name="org.apache.ibatis" level="DEBUG" additivity="false"><appender-ref ref="CONSOLE" /><appender-ref ref="FILE" /><appender-ref ref="Error" /></logger><!-- log4jdbc 옵션 설정 --><logger name="jdbc" level="OFF"/><!-- Connection open, close 이벤트에 대한 로그를 출력 --><logger name="jdbc.connection" level="OFF"/><!-- SQL문만을 로그로 출력하며, PreparedStatement일 경우 관련된 argument 값으로 대체된 SQL문이 출력 --><logger name="jdbc.sqlonly" level="OFF"/><!-- SQL문과 해당 SQL을 실행시키는데 수행된 시간 정보(milliseconds)를 출력 --><logger name="jdbc.sqltiming" level="DEBUG"/><!-- ResultSet을 제외한 모든 JDBC 호출 정보를 로그로 출력--><logger name="jdbc.audit" level="OFF"/><!-- ResultSet을 포함한 모든 JDBC 호출 정보를 로그로 출력 --><logger name="jdbc.resultset" level="OFF"/><!-- SQL 결과 조회된 데이터의 table을 로그로 출력 --><logger name="jdbc.resultsettable" level="DEBUG"/></configuration>cs 6. Console에서 로그 확인
Log4jdbc 옵션을 설정한 전, 후를 로그로 확인해보세요.
더보기1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011022020-05-12 16:10:31 [RMI TCP Connection(4)-127.0.0.1] [DEBUG] o.s.c.e.PropertySourcesPropertyResolver - Found key 'local.server.port' in PropertySource 'server.ports' with value of type Integer2020-05-12 16:10:33 [http-nio-8080-exec-1] [INFO ] o.a.c.c.C.[Tomcat].[localhost].[/] - Initializing Spring DispatcherServlet 'dispatcherServlet'2020-05-12 16:10:33 [http-nio-8080-exec-1] [INFO ] o.s.web.servlet.DispatcherServlet - Initializing Servlet 'dispatcherServlet'2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] o.s.web.servlet.DispatcherServlet - Detected StandardServletMultipartResolver2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] o.s.web.servlet.DispatcherServlet - enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data2020-05-12 16:10:33 [http-nio-8080-exec-1] [INFO ] o.s.web.servlet.DispatcherServlet - Completed initialization in 16 ms2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] o.s.web.servlet.DispatcherServlet - GET "/board", parameters={}2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped to com.api.board.controller.BoardController#getBoardList()2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@41205d36] was not registered for synchronization because synchronization is not active2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] o.s.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - HikariPool-1 - configuration:2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - allowPoolSuspension.............false2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - autoCommit......................true2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - catalog.........................none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - connectionInitSql...............none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - connectionTestQuery.............none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - connectionTimeout...............300002020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - dataSource......................none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - dataSourceClassName.............none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - dataSourceJNDI..................none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - dataSourceProperties............{password=<masked>}2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - driverClassName................."net.sf.log4jdbc.sql.jdbcapi.DriverSpy"2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - exceptionOverrideClassName......none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - healthCheckProperties...........{}2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - healthCheckRegistry.............none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - idleTimeout.....................6000002020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - initializationFailTimeout.......12020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - isolateInternalQueries..........false2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - jdbcUrl.........................jdbc:log4jdbc:mysql://localhost:3306/board?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - leakDetectionThreshold..........02020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - maxLifetime.....................18000002020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - maximumPoolSize.................102020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - metricRegistry..................none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - metricsTrackerFactory...........none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - minimumIdle.....................102020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - password........................<masked>2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - poolName........................"HikariPool-1"2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - readOnly........................false2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - registerMbeans..................false2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - scheduledExecutor...............none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - schema..........................none2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - threadFactory...................internal2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - transactionIsolation............default2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - username........................"board"2020-05-12 16:10:33 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.HikariConfig - validationTimeout...............50002020-05-12 16:10:33 [http-nio-8080-exec-1] [INFO ] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...2020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@46ee9e6a2020-05-12 16:10:34 [http-nio-8080-exec-1] [INFO ] com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.2020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] o.m.s.t.SpringManagedTransaction - JDBC Connection [HikariProxyConnection@1805604308 wrapping net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@46ee9e6a] will not be managed by Spring2020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] c.a.b.m.BoardMapper.getBoardList - ==> Preparing: SELECT * FROM ( SELECT BOARD_SEQ , BOARD_RE_REF , BOARD_RE_LEV , BOARD_RE_SEQ , BOARD_WRITER , BOARD_SUBJECT , BOARD_CONTENT , BOARD_HITS , DEL_YN , INS_USER_ID , CAST( DATE_FORMAT( INS_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS INS_DATE , UPD_USER_ID , CAST( DATE_FORMAT( UPD_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS UPD_DATE FROM BOARD.TB_BOARD ORDER BY BOARD_RE_REF DESC, BOARD_RE_SEQ ASC ) T12020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] c.a.b.m.BoardMapper.getBoardList - ==> Parameters:2020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] jdbc.sqltiming - com.zaxxer.hikari.pool.ProxyPreparedStatement.execute(ProxyPreparedStatement.java:44)1. SELECT *FROM (SELECT BOARD_SEQ, BOARD_RE_REF, BOARD_RE_LEV, BOARD_RE_SEQ, BOARD_WRITER, BOARD_SUBJECT, BOARD_CONTENT, BOARD_HITS, DEL_YN, INS_USER_ID, CAST( DATE_FORMAT( INS_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS INS_DATE, UPD_USER_ID, CAST( DATE_FORMAT( UPD_DATE, '%Y-%m-%d %H:%i:%s' ) AS CHAR(19) ) AS UPD_DATEFROM BOARD.TB_BOARDORDER BY BOARD_RE_REF DESC, BOARD_RE_SEQ ASC) T1{executed in 18 msec}2020-05-12 16:10:34 [HikariPool-1 housekeeper] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Pool stats (total=1, active=1, idle=0, waiting=0)2020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@379b02f62020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@76a608cd2020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@471a3f7c2020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@1689f7822020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@60c6313d2020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@12c78db22020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@2c93a1c02020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@794143312020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - Added connection net.sf.log4jdbc.sql.jdbcapi.ConnectionSpy@165b5a572020-05-12 16:10:34 [HikariPool-1 connection adder] [DEBUG] com.zaxxer.hikari.pool.HikariPool - HikariPool-1 - After adding stats (total=10, active=1, idle=9, waiting=0)2020-05-12 16:10:34 [http-nio-8080-exec-1] [INFO ] jdbc.resultsettable -|----------|-------------|-------------|-------------|-------------|--------------|--------------|-----------|-------|------------|--------------------|------------|---------||board_seq |board_re_ref |board_re_lev |board_re_seq |board_writer |board_subject |board_content |board_hits |del_yn |ins_user_id |ins_date |upd_user_id |upd_date ||----------|-------------|-------------|-------------|-------------|--------------|--------------|-----------|-------|------------|--------------------|------------|---------||1 |0 |0 |0 |게시글 작성자1 |게시글 제목1 |게시글 내용1 |0 |N |TEST01 |2020-05-11 16:50:25 |null |null ||2 |0 |0 |0 |게시글 작성자2 |게시글 제목2 |게시글 내용2 |0 |N |TEST02 |2020-05-11 16:50:26 |null |null ||3 |0 |0 |0 |게시글 작성자3 |게시글 제목3 |게시글 내용3 |0 |N |TEST03 |2020-05-11 16:50:27 |null |null ||4 |0 |0 |0 |게시글 작성자4 |게시글 제목4 |게시글 내용4 |0 |N |TEST04 |2020-05-11 16:50:29 |null |null ||5 |0 |0 |0 |게시글 작성자5 |게시글 제목5 |게시글 내용5 |0 |N |TEST05 |2020-05-11 16:50:30 |null |null ||----------|-------------|-------------|-------------|-------------|--------------|--------------|-----------|-------|------------|--------------------|------------|---------|2020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] c.a.b.m.BoardMapper.getBoardList - <== Total: 52020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@41205d36]2020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Using 'application/json', given [*/*] and supported [application/json, application/*+json, application/json, application/*+json]2020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] o.s.w.s.m.m.a.RequestResponseBodyMethodProcessor - Writing [[com.api.board.domain.Board@227dd915, com.api.board.domain.Board@47131957, com.api.board.domain.Boar (truncated)...]2020-05-12 16:10:34 [RMI TCP Connection(4)-127.0.0.1] [DEBUG] o.s.c.e.PropertySourcesPropertyResolver - Found key 'local.server.port' in PropertySource 'server.ports' with value of type Integer2020-05-12 16:10:34 [http-nio-8080-exec-1] [DEBUG] o.s.web.servlet.DispatcherServlet - Completed 200 OK2020-05-12 16:10:37 [RMI TCP Connection(4)-127.0.0.1] [DEBUG] o.s.c.e.PropertySourcesPropertyResolver - Found key 'local.server.port' in PropertySource 'server.ports' with value of type Integercs 소스 코드는 Github Repository - https://github.com/tychejin1218/api-board_v1 (branch : section04) 를 참조하세요.
Github에서 프로젝트 가져오기 - https://tychejin.tistory.com/33반응형'Spring Boot > 2.4.x - REST API 만들기' 카테고리의 다른 글
[Spring Boot] REST API 만들기(6) - Interceptor 적용 (1) 2020.05.07 [Spring Boot] REST API 만들기(5) - Mapper 구현 및 단위 테스트(Junit4) (0) 2020.05.06 [Spring Boot] REST API 만들기(3) - Logback 설정 (0) 2020.05.04 [Spring Boot] REST API 만들기(2) - MySQL + MyBatis 연동 (0) 2020.05.03 [Spring Boot] REST API 만들기(1) - 프로젝트 생성 (0) 2020.04.29