How to enable query debugging in Bamboo

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

目的

In order to debug some Bamboo problems, we might need to see what queries Bamboo is running against the database.

Please note that this type of debugging will rapidly increase your log size and might affect the Bamboo general performance.

ソリューション

  1. Stop Bamboo
  2. Edit <BAMBOO_HOME>/bamboo.cfg.xml and add the following properties inside the <properties> section:

    <property name="hibernate.format_sql">true</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.use_sql_comments">true</property>

    Adding those properties to the configuration file is enough to display the SQL statements executed by the application via JDBC to the log files.

  3. If you also want to get the values bound to the JDBC parameters displayed by the properties above, then please edit the <BAMBOO_INSTALL>/atlassian-bamboo/WEB-INF/classes/log4j.properties and add the following line in the database block:

    log4j.logger.org.hibernate.type=TRACE
  4. Start Bamboo

  5. Once you restart the application, please go to Bamboo administration > Overview > System > Log settings and make sure the org.hibernate.SQL package is set to DEBUG.
    1. Some versions of Bamboo have this property set to INFO after restarting the application, even though show_sql was set to true in step 2 – which means, org.hibernate.SQL should be set to DEBUG.

結果

This configuration will allow you to see both the query and the values used.

Hibernate:
    /* load com.atlassian.bamboo.plan.branch.BranchCommitInformationImpl */ select
        branchcomm0_.BRANCH_COMMIT_INFO_ID as BRANCH_C1_11_0_,
        branchcomm0_.BRANCH_ID as BRANCH_I2_11_0_,
        branchcomm0_.CREATING_AUTHOR_ID as CREATING3_11_0_,
        branchcomm0_.CREATING_COMMIT_DATE as CREATING4_11_0_,
        branchcomm0_.CREATING_CHANGE_SET_ID as CREATING5_11_0_,
        branchcomm0_.LATEST_COMMIT_AUTHOR_ID as LATEST_C6_11_0_,
        branchcomm0_.LATEST_COMMIT_DATE as LATEST_C7_11_0_,
        branchcomm0_.LATEST_COMMIT_CHANGE_SET_ID as LATEST_C8_11_0_
    from
        BRANCH_COMMIT_INFO branchcomm0_
    where
        branchcomm0_.BRANCH_ID=?
2017-09-07 16:18:11,692 TRACE [10-BAM::PlanExec:pool-18-thread-3] [BasicBinder] binding parameter [1] as [BIGINT] - [92504065]
2017-09-07 16:18:11,693 TRACE [10-BAM::PlanExec:pool-18-thread-3] [BasicExtractor] extracted value ([BRANCH_C1_11_0_] : [BIGINT]) - [92798978]
2017-09-07 16:18:11,693 TRACE [10-BAM::PlanExec:pool-18-thread-3] [BasicExtractor] extracted value ([BRANCH_I2_11_0_] : [BIGINT]) - [92504065]
2017-09-07 16:18:11,693 TRACE [10-BAM::PlanExec:pool-18-thread-3] [BasicExtractor] extracted value ([CREATING3_11_0_] : [BIGINT]) - [null]
2017-09-07 16:18:11,693 TRACE [10-BAM::PlanExec:pool-18-thread-3] [BasicExtractor] extracted value ([CREATING4_11_0_] : [TIMESTAMP]) - [null]
2017-09-07 16:18:11,693 TRACE [10-BAM::PlanExec:pool-18-thread-3] [BasicExtractor] extracted value ([CREATING5_11_0_] : [VARCHAR]) - [null]
2017-09-07 16:18:11,693 TRACE [10-BAM::PlanExec:pool-18-thread-3] [BasicExtractor] extracted value ([LATEST_C6_11_0_] : [BIGINT]) - [49905666]
2017-09-07 16:18:11,693 TRACE [10-BAM::PlanExec:pool-18-thread-3] [BasicExtractor] extracted value ([LATEST_C7_11_0_] : [TIMESTAMP]) - [2017-08-30 09:14:55.763]
2017-09-07 16:18:11,693 TRACE [10-BAM::PlanExec:pool-18-thread-3] [BasicExtractor] extracted value ([LATEST_C8_11_0_] : [VARCHAR]) - [49994]



最終更新日 2018 年 11 月 14 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.