Jira サーバーで SQL クエリのロギングを有効化する
目的
このナレッジベース記事では、Jira 内の詳細な SQL ロギングを有効化する方法を説明します。これは次のような場合に使用できます。
- データベースの SQL の問題のトラブルシューティング
- 特定のユーザー アクションで送信された SQL を判断するための、GUI アクションのリバースエンジニアリング
This is broken down into two sections, OfBiz and Active Objects. They are both persistence ORM frameworks which means they're libraries that can be used to manage the SQL sent to different database systems.
- OfBiz: Used by standard JIRA functionality.
- Active Objects: Used by plugins, both third-party and bundled. Active Objects tables can be identified as they're named
AO_<code>_TABLENAME
.
It's important to note enabling SQL logging on production instances may cause a performance degradation on Jira, impacting the ability of end-users to conduct their work.
When possible, work on a lower environment or outside business hours to minimize impact on end-users. If that's not possible, you may consider enabling DEBUG level logs instead of TRACE to reduce the amount of logs generated and also slow down how often these logs will rotate.
ソリューション
SQL ロギングを一時的に有効化する方法
- Jira に管理者としてログインします。
[管理] > [システム] > [ロギングとプロファイリング] に移動します。
OfBiz の場合:
次のように SQL ロギングを有効化します。
結果のログは
<JIRA HOME>/log/atlassian-jira-sql.log
に記録されます。
Active Objects の場合:
Search for net.java.ao.sql and set it to
TRACE
:- In the logging page, click at the Configure option as shown below. Add the package com.querydsl.sql and set it to TRACE:
結果のログは
<JIRA HOME>/log/atlassian-jira.log
に記録されます。
これらの設定はメモリに保管されるため、再起動すると失われます。
SQL ロギングを永続的に有効化する方法
- Jira で設定を保持したい場合、
log4j.properties
ファイルで設定を変更します。例: OfBiz については、この
OFF
をON
に設定します。log4j.logger.com.atlassian.jira.ofbiz.LoggingSQLInterceptor = OFF, sqllog
Active Objects については、
WARN
をTRACE
に設定します。log4j.logger.net.java.ao.sql = WARN, console, filelog # Append the following at the end of the file log4j.logger.com.querydsl.sql = TRACE, console, sqllog log4j.additivity.com.querydsl.sql = false
ファイル サイズの構成
デフォルトの構成では、ローリングされるログ ファイルが 5 個 (サイズは 20 MB、合計で最大 100 MB) 許可されます。この設定を調整するには log4j.properties
ファイルを更新します。