> ## 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_* 会话设置

> 按 log_* 生成的分组中的 ClickHouse 会话设置。

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_comment">
  ## log\_comment
</div>

指定 [system.query\_log](/docs/zh/reference/system-tables/query_log) 表中 `log_comment` 字段的值，以及服务器日志中的注释文本。

它可用于提高服务器日志的可读性。此外，在运行 [clickhouse-test](/docs/zh/resources/develop-contribute/contribute/tests) 后，它还有助于从 `system.query_log` 中筛选与测试相关的查询。

可能的值：

* 不超过 [max\_query\_size](/docs/zh/reference/settings/session-settings/max#max_query_size) 的任意字符串。如果超过 max\_query\_size，服务器会抛出异常。

**示例**

查询：

```sql theme={null}
SET log_comment = 'log_comment test', log_queries = 1;
SELECT 1;
SYSTEM FLUSH LOGS;
SELECT type, query FROM system.query_log WHERE log_comment = 'log_comment test' AND event_date >= yesterday() ORDER BY event_time DESC LIMIT 2;
```

结果：

```text theme={null}
┌─type────────┬─query─────┐
│ QueryStart  │ SELECT 1; │
│ QueryFinish │ SELECT 1; │
└─────────────┴───────────┘
```

<div id="log_formatted_queries">
  ## log\_formatted\_queries
</div>

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

允许将格式化后的查询记录到 [system.query\_log](/docs/zh/reference/system-tables/query_log) 系统表中 (即填充 [system.query\_log](/docs/zh/reference/system-tables/query_log) 中的 `formatted_query` 列) 。

可能的值：

* 0 — 不会将格式化后的查询记录到系统表中。
* 1 — 会将格式化后的查询记录到系统表中。

<div id="log_processors_profiles">
  ## log\_processors\_profiles
</div>

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

<VersionHistory rows={[{"id": "row-1","items": [{"label": "24.3"},{"label": "1"},{"label": "默认启用"}]}]} />

将处理器在执行过程中以及等待数据时耗费的时间写入 `system.processors_profile_log` 表。

另请参见：

* [`system.processors_profile_log`](/docs/zh/reference/system-tables/processors_profile_log)
* [`EXPLAIN PIPELINE`](/docs/zh/reference/statements/explain#explain-pipeline)

<div id="log_profile_events">
  ## log\_profile\_events
</div>

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

将查询性能统计信息写入 query\_log、query\_thread\_log 和 query\_views\_log。
