Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLのログ出力機能の追加 #69

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

SQLのログ出力機能の追加 #69

wants to merge 6 commits into from

Conversation

mygreen
Copy link
Owner

@mygreen mygreen commented May 4, 2023

変更内容

  • ログ出力用のプロパティの追加。(07eb1a9)
  • 各SQL実行クラスにて、ログ出力処理の呼び出しを追加。(a338eeb)
  • テスタ実行時にSQLログ出力の有効設定を追加。(a1d9a0c)
  • サンプル実行時にSQLログ出力の有効設定を追加。(f3d8314)
  • ストアドプロシージャ/ファンクションのSQLログ出力の追加(496a609)

使用方法

SqlMapperの設定でログ出力機能を有効にします。

# application.yml
sqlmapper:
  show-sql:
    enabled: true   # SQLのログ出力機能の有効化
    log-level: debug
    bind-param:
      enabled: true # バインド変数も出力するかどうか。
      log-level: debug

ロガーの設定として、com.github.mygreen.sqlmapper.core.query.SqlLogger を出力対象とします。

# loback.xml
<configuration>

	<!-- 実行SQL出力設定 -->
	<logger name="com.github.mygreen.sqlmapper.core.query.SqlLogger" level="DEBUG" additivity="false">
		<appender-ref ref="xxx" />
	</logger>

</configuration>

ログには、以下のように出力されます。

.11:34:40.288 [main]  [39mDEBUG [0;39m  [36mc.g.m.s.c.q.SqlLogger [0;39m - sql statement : select T1_.customer_id, T1_.FIRST_NAME, T1_.LAST_NAME, T1_.BIRTHDAY, T1_.GENDER_TYPE, T1_.VERSION from CUSTOMER T1_ where T1_.BIRTHDAY < ? order by T1_.BIRTHDAY DESC 
.11:34:40.290 [main]  [39mDEBUG [0;39m  [36mc.g.m.s.c.q.SqlLogger [0;39m - sql binding parameter : [1] as [DATE] - [2000-01-01] 

@mygreen mygreen added this to the 0.4 milestone May 5, 2023
@mygreen mygreen added the enhancement New feature or request label May 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant