Back-End ์ž‘์—…์‹ค/Spring Framework

[SpringBoot][MyBatis] Logging(Show SQL Query)

์ฃผ๋‹ˆ์“ฐ๐Ÿง‘‍๐Ÿ’ป 2022. 6. 19. 06:45
728x90
๋ฐ˜์‘ํ˜•

 

 

Git Hub ์ฃผ์†Œ : https://github.com/junyharang-Development-Lab/mybatis-paging-search-test/tree/main

 

 

๐Ÿš€ Mybatis Logging (Show SQL Query)

    ๐Ÿ”ฝ  ์˜์กด์„ฑ ์„ค์ •

        ๐Ÿ“ฆ build.gradle

	// SQL query show
	implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4.1:1.16'


์ตœ์ดˆ ์˜์กด์„ฑ ์ถ”๊ฐ€๋ฅผ ์œ„ํ•ด ์œ„์™€ ๊ฐ™์ด ์˜์กด์„ฑ ๋‚ด์šฉ์„ ๋“ฑ๋กํ•ด ์ค๋‹ˆ๋‹ค.

์ฐธ๊ณ ๋กœ Log4j์˜ ๊ฒฝ์šฐ ์ตœ๊ทผ ์ทจ์•ฝ์  ๋ฐ ํ•ด์ปค์˜ ๊ณต๊ฒฉ ๋“ฑ์œผ๋กœ Issue๊ฐ€ ๋งค์šฐ ๋งŽ์•˜์Œ์œผ๋กœ ์ž˜ ํ™•์ธํ•˜์‹œ๊ณ , ์‚ฌ์šฉํ•˜์‹œ๊ธธ ๊ถŒ๊ณ  ๋“œ๋ฆฝ๋‹ˆ๋‹ค.





    ๐Ÿ”ฝ  ๊ตฌ์„ฑ

        ๐Ÿ“ฆ application.yml

spring:
  datasource:
    driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
    url: jdbc:log4jdbc:mariadb://{DataBase IP ์ •๋ณด}:{DataBase Port ๋ฒˆํ˜ธ}/{DataBase ์ด๋ฆ„}?serverTimezone=UTC&characterEncoding=UTF-8
    username: {DataBase User ID}
    password: {DataBase User Password}
๋ฐ˜์‘ํ˜•


๊ทธ๋Ÿฐ ๋‹ค์Œ application.yml์— ์œ„์˜ driver-class-name๊ณผ url์— log4jdb๋ฅผ ์ถ”๊ฐ€ํ•œ ๋‚ด์šฉ์„ ๊ธฐ์žฌํ•ด ์ค๋‹ˆ๋‹ค.

 

 

    ๐Ÿ”ฝ  ๊ฒฐ๊ณผ

        ๐Ÿ“ฆ ์ถœ๋ ฅ ๋‚ด์šฉ

InteliJ ์ถœ๋ ฅ ๊ฒฐ๊ณผ

 

 

 

 

 

 

 

728x90
๋ฐ˜์‘ํ˜•