How to Enable Detailed SQL Logging

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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.

*Except Fisheye and Crucible

Summary

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)

Environment

All supported versions of Bamboo.

Solution

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:

    ClasspathType
    org.hibernate.type.descriptor.sql.BasicBinder
    ALL
    org.hibernate.resource.jdbc.internal.ResourceRegistryStandardImpl
    ALL

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.


Last modified on Oct 31, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.