> ## Documentation Index
> Fetch the complete documentation index at: https://clickhouse.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# log_query_* 会话设置

> ClickHouse 在 log_query_* 分组中的会话设置。

export const SettingsInfoBlock = ({type, default_value, changeable_without_restart}) => {
  return <div className="not-prose" style={{
    display: "flex",
    flexWrap: "wrap",
    alignItems: "baseline",
    columnGap: "0.5rem",
    rowGap: "0.125rem",
    margin: "0.375rem 0",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <div style={{
    fontWeight: 600,
    opacity: 0.72
  }}>类型</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>默认值</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          无需重启即可更改
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

这些设置可在 [system.settings](/docs/zh/reference/system-tables/settings) 中找到，并由 [源代码](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) 自动生成。

<div id="log_query_settings">
  ## log\_query\_settings
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

将查询设置写入 query\_log 和 OpenTelemetry span 日志。

<div id="log_query_threads">
  ## log\_query\_threads
</div>

<SettingsInfoBlock type="Bool" default_value="0" />

设置是否记录查询线程日志。

查询线程会记录到 [system.query\_thread\_log](/docs/zh/reference/system-tables/query_thread_log) 表中。此设置仅在 [log\_queries](/docs/zh/reference/settings/session-settings/log-queries#log_queries) 为 true 时生效。启用此设置后，ClickHouse 运行的查询线程会按照服务器配置参数 [query\_thread\_log](/docs/zh/reference/settings/server-settings/settings#query_thread_log) 中的规则进行记录。

可能的值：

* 0 — 禁用。
* 1 — 启用。

**示例**

```text theme={null}
log_query_threads=1
```

<div id="log_query_views">
  ## log\_query\_views
</div>

<SettingsInfoBlock type="Bool" default_value="1" />

启用查询视图日志记录。

当 ClickHouse 在启用此设置时执行的查询存在关联视图 (materialized 或 live view) 时，这些视图会记录到 [query\_views\_log](/docs/zh/reference/settings/server-settings/settings#query_views_log) 服务器配置参数中。

示例：

```text theme={null}
log_query_views=1
```
