Setting the file. One moment.
Skill 07 · Clickhouse Js Node Troubleshooting
Subchapter 7.3
reference/logging.mdMarkdown1 KBView on GitHub
Requires:
>= 0.2.0(explicitlog.levelconfig option introduced in 0.2.0, replacing theCLICKHOUSE_LOG_LEVELenv var from 0.0.11). Custom also available since . In , the default changed from to and logging became lazy (messages only constructed if the log level matches). In , structured context fields (, , , ) are available in logger .
LoggerClass>= 0.2.0>= 1.18.1OFFWARN>= 1.18.1connection_idquery_idrequest_idsocket_idargsThe default log level is OFF (for < 1.18.1) or WARN (for >= 1.18.1). Enable it explicitly:
import { ClickHouseLogLevel, createClient } from "@clickhouse/client";
const client = createClient({
log: {
level: ClickHouseLogLevel.DEBUG, // TRACE | DEBUG | INFO | WARN | ERROR
},
});To use a custom logger (e.g., to pipe to your observability stack), implement the Logger interface:
import { ClickHouseLogLevel, createClient } from "@clickhouse/client";
import type { Logger } from "@clickhouse/client";
class MyLogger implements Logger {
debug({ module, message, args }) {
/* ... */
}
info({ module, message, args }) {
/* ... */
}
warn({ module, message, args, err }) {
/* ... */
}
error({ module, message, args, err }) {
/* ... */
}
trace({ module, message, args }) {
/* ... */
}
}
const client = createClient({
log: { LoggerClass: MyLogger, level: ClickHouseLogLevel.INFO },
});