How to Enable Detailed SQL Logging

お困りですか?

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

コミュニティに質問

プラットフォームについて: Server および Data Center のみ。この記事は、Server および Data Center プラットフォームのアトラシアン製品にのみ適用されます。

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Fisheye および Crucible は除く

要約

Bamboo uses the open-source persistence framework Hibernate. This page tells you how to configure Bamboo's logging to report individual SQL requests that are sent to the database by Hibernate. It is useful for troubleshooting the following events:

  • Database Corruption
  • Exceptions caused by an illegal database operation
  • Any Database specific error(s)

環境

All supported versions of Bamboo.

ソリューション

It is advisable to enable detailed SQL logging before sending us the log files so, after you have enabled enhanced logging, please replicate the action that was causing the error in the first place and then generate a Support Zip. This will assist us in determining what SQL queries were running during the reported problem.

 Enabling detailed SQL logging greatly increases the amount of log output produced, potentially resulting in increased disk usage. Ensure you have sufficient disk space available and disable detailed SQL logging once you no longer need it.

Enabling SQL logging using Log4j

Bamboo versions 7.x

  1. Stop Bamboo.
  2. Edit the log4j.properties file located in <bamboo-install>/atlassian-bamboo/WEB-INF/classes
  3. Add the following lines to log4j.properties:

    log4j.logger.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
    log4j.logger.org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl=TRACE
  4. Start Bamboo

Bamboo versions 8.x

Bamboo 8.x series uses a different logging strategy that requires changes to <bamboo-home>/bamboo.cfg.xml. Adding debug classes for hibernate will not work on the UI or log4j.properties

  1. Stop Bamboo.
  2. Add the following properties to <bamboo-home>/bamboo.cfg.xml:

    <property name="hibernate.format_sql">true</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.use_sql_comments">true</property>
  3. Start Bamboo
  4. The queries output will be sent to either on <bamboo-install>/logs/catalina.out or on the standard output in the case of running Bamboo in Docker for example

Bamboo versions 9.x

  1. Stop Bamboo.
  2. Edit log4j2.properties, located in <bamboo-install>/atlassian-bamboo/WEB-INF/classes.
  3. Add the following lines to log4j2.properties:

    logger.bamboo-binder.level=TRACE
    logger.bamboo-binder.name=org.hibernate.type.descriptor.sql.BasicBinder
    
    logger.bamboo-registry.level=TRACE
    logger.bamboo-registry.name=org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl
  4. Start Bamboo

Enabling SQL logging in the Bamboo UI

  1. Only valid for Bamboo 7.x and 9.x
  2. Access Administration > Overview > Log settings
  3. Add the following log settings:

    Classpathタイプ
    org.hibernate.type.descriptor.sql.BasicBinder
    すべて
    org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl
    すべて

Disable Batched Updates

  1. Stop Bamboo
  2. Edit <bamboo-home>/bamboo.cfg.xml and add the following hibernate.jdbc.batch_size property line:

    <application-configuration>
      ...
      <properties>
        ...
        <property name="hibernate.jdbc.batch_size">0</property>
        ...
      </properties>
    </application-configuration>
  3. Start Bamboo.


最終更新日: 2022 年 10 月 31 日

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

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