KBEC-00086 - Enabling and collecting voluminous JDBC logging

Article ID:360033194451
2 minute readKnowledge base

Issue

The Java Database Connectivity (JDBC) API is the industry standard for database-independent connectivity between the Java programming language and a wide range of databases and other tabular data sources, such as spreadsheets or flat files.

This article describes how to enable JDBC additional logging for debug purposes.

Resolution

10.6 and newer:

  1. In the CloudBees CD Server, open the logging-local.properties file, which is located in yourInstallationPath/conf, and append the following section:

    # Log all SQL DML statements as they are executed
    org.hibernate.SQL=TRACE
    # Log all JDBC parameters
    org.hibernate.type.descriptor.sql.BasicBinder=TRACE
  2. Once these changes are saved, confirm the additional SQL trace logging lines are added to the yourInstallationPath/logs/commander.log file (in clustered installations the log is generated in the file commander-yourHostName.log) by checking if this command returns a count greater than 0:

    grep " SQL              " commander.log | wc -l
    3275
  3. Do the same for BasicBinder trace logging:

    grep " BasicBinder      " commander.log | wc -l
    234819
  4. If this change does not take effect (previous grep commands return 0), restart the CloudBees CD (CloudBees Flow) server and run the grep commands again after restarting (this might be required for very busy servers).

  5. Reproduce the issue that you are trying to debug.

  6. Provide to the support team all the logs from the time you turned on JDBC logging until after the issue is reproduced.

Pre 10.6:

  1. In the CloudBees CD Server, open the logback-local.groovy file, which is located in yourInstallationPath/conf, and find the following section:

     // Log all SQL DML statements as they are executed
     logger("org.hibernate.SQL", TRACE)
     // Log all JDBC parameters
     logger("org.hibernate.type.descriptor.sql.BasicBinder", TRACE)
  2. Ensure that the lines are uncommented and that the level is set to "TRACE".

  3. Once these changes are saved, confirm the additional SQL trace logging lines are added to the yourInstallationPath/logs/commander.log file (in clustered installations the log is generated in the file commander-yourHostName.log) by checking if this command returns a count greater than 0:

    grep " SQL              " commander.log | wc -l
    3275
  4. Do the same for BasicBinder trace logging:

    grep " BasicBinder      " commander.log | wc -l
    234819
  5. If this change does not take effect (previous grep commands return 0), restart the CloudBees CD (CloudBees Flow) server and run the grep commands again after restarting (this might be required for very busy servers).

  6. Reproduce the issue that you are trying to debug.

  7. Provide to the support team all the logs from the time you turned on JDBC logging until after the issue is reproduced.