From 5a75eb904cb8f38390ea8cd75d0bb5f85a782f1e Mon Sep 17 00:00:00 2001 From: LjungeldTheHelper <352537209+LjungeldTheHelper@users.noreply.github.com> Date: Wed, 4 Nov 2026 17:13:23 -0800 Subject: [PATCH 1/2] Document what client-v2 and jdbc-v2 log and a safe logging configuration (#3295) Adds copy-ready Logback and Log4j 2 configurations that keep the client, the driver and the Apache HttpClient header and wire loggers (unshaded, client-v2 `all` and clickhouse-jdbc-all names) at INFO, and documents the logging contract of client-v2 and jdbc-v2. Corrects the shaded logger prefix of clickhouse-jdbc-all. Co-Authored-By: Claude Opus 5.5 --- docs/clickhouse-docs/index.mdx | 83 +++++++++++++++++++++++++++++++++- docs/clickhouse-docs/jdbc.mdx | 1 + 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/docs/clickhouse-docs/index.mdx b/docs/clickhouse-docs/index.mdx index 105c1d2c4..d3265311c 100644 --- a/docs/clickhouse-docs/index.mdx +++ b/docs/clickhouse-docs/index.mdx @@ -197,6 +197,87 @@ This is going to depend on the logging framework you're using. For example, if y The client (`client-v2`) and the JDBC driver (`jdbc-v2`) never write HTTP wire logs, which are the bytes of requests and responses, to the Apache HttpClient logger `org.apache.hc.client5.http.wire`. This is also true when that logger or the root logger is set to `DEBUG`. Wire logs contain credentials, SQL, and data. To examine HTTP traffic, use a packet capture in a test environment with test credentials. -The Apache HttpClient logger `org.apache.hc.client5.http.headers` writes the request headers, including `Authorization`, at `DEBUG`. Keep it at `INFO` or higher in production. In a shaded artifact (for example `client-v2` with the `all` classifier, or `clickhouse-jdbc-all`), the Apache HttpClient logger names start with the relocation prefix of that artifact, for example `com.clickhouse.shaded.org.apache.hc.client5.http.headers`. +The Apache HttpClient logger `org.apache.hc.client5.http.headers` writes the request headers, including `Authorization`, at `DEBUG`. Keep it at `INFO` or higher in production. In a shaded artifact, the Apache HttpClient logger names start with the relocation prefix of that artifact: `com.clickhouse.shaded.` for `client-v2` with the `all` classifier (for example `com.clickhouse.shaded.org.apache.hc.client5.http.headers`), and `com.clickhouse.client.internal.` for `clickhouse-jdbc-all`, which also contains the unshaded names. The configurations below set all of these names. + +#### What the client and the driver log {#what-the-client-logs} + +The client (`client-v2`) and the JDBC driver (`jdbc-v2`) keep their logs free of application data at every level, `TRACE` included. They never log: + +- SQL statements, bound parameter values, rows, or request and response bodies +- credentials, tokens, or header values +- full URLs or URL query strings, and configuration values +- the client name and client metadata, and query IDs +- the message of an exception: a message can quote SQL, a value, an endpoint, or a server response + +An exception that is thrown to the application is not logged as well; it carries the details. The levels are used as follows: + +- `ERROR`: a failure that cannot be reported to the application, for example a failed driver registration. +- `WARN`: a state that degrades the client, reported once: an operation that succeeded after retries (with the retry count and the type of the last failure, once per operation), an endpoint that is quarantined (with its host name only, once per quarantine), all endpoints unavailable (once until an endpoint is available again), ignored or conflicting configuration (with the names of the options only), and a server error message that cannot be read. +- `DEBUG`: bounded diagnostics, such as the settings a client was created with and cleanup failures (with the type of the failure). `DEBUG` messages are not written per row, per value, per retry, or per metadata object. + +For deeper diagnosis use the client metrics and spans (see [Observability & Monitoring](/integrations/language-clients/java/client#v2-o11y)), or a packet capture in a test environment with test credentials. + +#### Safe logging configuration {#safe-logging-configuration} + +The configuration below keeps the client, the driver, and the Apache HttpClient header and wire loggers at `INFO`. The explicit levels of the Apache HttpClient loggers also apply when the root logger is set to `DEBUG`. Use `OFF` instead of `INFO` to silence these loggers completely. + +```xml title="logback.xml" + + + + [%d{yyyy-MM-dd HH:mm:ss}] [%level] [%thread] %logger{36} - %msg%n + + + + + + + + + + + + + + + + + + + + + +``` + +With Log4j 2, add the `org.apache.logging.log4j:log4j-slf4j2-impl` binding and use: + +```xml title="log4j2.xml" + + + + + + + + + + + + + + + + + + + + + + + + + + +``` [Changelog](https://github.com/ClickHouse/clickhouse-java/blob/main/CHANGELOG.md) diff --git a/docs/clickhouse-docs/jdbc.mdx b/docs/clickhouse-docs/jdbc.mdx index 8e97ad506..37114f83b 100644 --- a/docs/clickhouse-docs/jdbc.mdx +++ b/docs/clickhouse-docs/jdbc.mdx @@ -831,6 +831,7 @@ For more information, see our [GitHub repository](https://github.com/ClickHouse/ ### Logging {#logging} The driver uses [slf4j](https://www.slf4j.org/) for logging, and will use the first available implementation on the `classpath`. The driver never writes HTTP wire logs. See [HTTP wire logs](/integrations/java#http-wire-logs). +The driver does not log SQL, parameter values, credentials, or other application data at any level, `TRACE` included. See [What the client and the driver log](/integrations/java#what-the-client-logs) and the copy-ready [Safe logging configuration](/integrations/java#safe-logging-configuration) for Logback and Log4j 2. ### Resolving JDBC Timeout on Large Inserts {#resolving-jdbc-timeout-on-large-inserts} From 5e194b18b12bf236bc3e2cc6d705fb21ebf58281 Mon Sep 17 00:00:00 2001 From: LjungeldTheHelper <352537209+LjungeldTheHelper@users.noreply.github.com> Date: Mon, 9 Nov 2026 11:49:20 -0800 Subject: [PATCH 2/2] Document that query IDs, server addresses and stack traces stay in logs (#3295) Co-Authored-By: Claude Opus 5.5 --- docs/clickhouse-docs/index.mdx | 12 ++++++------ docs/clickhouse-docs/jdbc.mdx | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/clickhouse-docs/index.mdx b/docs/clickhouse-docs/index.mdx index d3265311c..d7619ed7f 100644 --- a/docs/clickhouse-docs/index.mdx +++ b/docs/clickhouse-docs/index.mdx @@ -201,19 +201,19 @@ The Apache HttpClient logger `org.apache.hc.client5.http.headers` writes the req #### What the client and the driver log {#what-the-client-logs} -The client (`client-v2`) and the JDBC driver (`jdbc-v2`) keep their logs free of application data at every level, `TRACE` included. They never log: +The client (`client-v2`) and the JDBC driver (`jdbc-v2`) do not log the data of the application at any level, `TRACE` included. They never log: - SQL statements, bound parameter values, rows, or request and response bodies - credentials, tokens, or header values - full URLs or URL query strings, and configuration values -- the client name and client metadata, and query IDs -- the message of an exception: a message can quote SQL, a value, an endpoint, or a server response +- the client name and client metadata -An exception that is thrown to the application is not logged as well; it carries the details. The levels are used as follows: +Query IDs are not sensitive. The client logs the query ID and the server address (host and port) with request failures and server errors, so that you can find the query in `system.query_log`. A request without a query ID is logged as `unknown`. A logged failure carries its exception with the stack trace. The message of a server error can quote parts of the SQL, so the `DEBUG` log of a failed request can contain these parts. The levels are used as follows: - `ERROR`: a failure that cannot be reported to the application, for example a failed driver registration. -- `WARN`: a state that degrades the client, reported once: an operation that succeeded after retries (with the retry count and the type of the last failure, once per operation), an endpoint that is quarantined (with its host name only, once per quarantine), all endpoints unavailable (once until an endpoint is available again), ignored or conflicting configuration (with the names of the options only), and a server error message that cannot be read. -- `DEBUG`: bounded diagnostics, such as the settings a client was created with and cleanup failures (with the type of the failure). `DEBUG` messages are not written per row, per value, per retry, or per metadata object. +- `WARN`: a state that degrades the client, reported once: a server error response (with the query ID and the server address), an operation that succeeded after retries (with the retry count and the type of the last failure, once per operation), an endpoint that is quarantined (with its host name only, once per quarantine), all endpoints unavailable (once until an endpoint is available again), ignored or conflicting configuration (with the names of the options only), and a server error message that cannot be read. +- `DEBUG`: bounded diagnostics, such as the settings a client was created with, failed requests (with the server address and the exception), and cleanup failures (with the exception). `DEBUG` messages are not written per row, per value, per retry, or per metadata object. +- `TRACE`: detailed diagnostics, for example an insert that the SQL parser handles as a function call, or a column type that cannot be mapped to a JDBC type. For deeper diagnosis use the client metrics and spans (see [Observability & Monitoring](/integrations/language-clients/java/client#v2-o11y)), or a packet capture in a test environment with test credentials. diff --git a/docs/clickhouse-docs/jdbc.mdx b/docs/clickhouse-docs/jdbc.mdx index 37114f83b..76753b930 100644 --- a/docs/clickhouse-docs/jdbc.mdx +++ b/docs/clickhouse-docs/jdbc.mdx @@ -831,7 +831,7 @@ For more information, see our [GitHub repository](https://github.com/ClickHouse/ ### Logging {#logging} The driver uses [slf4j](https://www.slf4j.org/) for logging, and will use the first available implementation on the `classpath`. The driver never writes HTTP wire logs. See [HTTP wire logs](/integrations/java#http-wire-logs). -The driver does not log SQL, parameter values, credentials, or other application data at any level, `TRACE` included. See [What the client and the driver log](/integrations/java#what-the-client-logs) and the copy-ready [Safe logging configuration](/integrations/java#safe-logging-configuration) for Logback and Log4j 2. +The driver does not log SQL, parameter values, credentials, or other application data at any level, `TRACE` included. The client logs query IDs and the server address with request failures. See [What the client and the driver log](/integrations/java#what-the-client-logs) and the copy-ready [Safe logging configuration](/integrations/java#safe-logging-configuration) for Logback and Log4j 2. ### Resolving JDBC Timeout on Large Inserts {#resolving-jdbc-timeout-on-large-inserts}