Advanced usage of Databricks Connect for Scala


This article covers Databricks Connect for Databricks Runtime 14.3 and above.

This article describes topics that go beyond the basic set up of Databricks Connect.

Logging and debug logs

Databricks Connect for Scala uses SLF4J logging, and does not ship with any SLF4J providers.

Applications using Databricks Connect are expected to include an SLF4J provider that is suitable to them.

A suitable logging provider needs to be added, and in some cases, configured to print the log messages. The simplest option is to include the slf4j-simple provider which will print log messages at the INFO level and higher to the standard error stream (stderr).

A more configurable alternative is to use the slf4j-reload4j provider which picks up configuration from a file in the classpath.

The following code snippet shows a simple file.



In the preceding example, debug logs will be printed if the root logger or a specific logger is configured at the DEBUG level, that is, by changing the line:



If your cluster relies on a custom SSL/TLS certificate to resolve a Databricks workspace fully qualified domain name (FQDN), you must set the environment variable GRPC_DEFAULT_SSL_ROOTS_FILE_PATH on your local development machine. This environment variable must be set to the full path to the installed certificate on the cluster.

For example, you set this environment variable in Scala code as follows:

import scala.sys.process._

val envValue = "/etc/ssl/certs/ca-bundle.crt"

// Setting the environment variable
val process = Process(Seq("bash", "-c", s"export $envVar=$envValue"))

For other ways to set environment variables, see your operating system’s documentation.