> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-postgresql-tls-support.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# log_* 会话设置

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

export const VersionHistory = ({rows = []}) => {
  if (rows.length === 0) {
    return null;
  }
  const headers = ["版本", "默认值", "注释"];
  const border = "1px solid rgba(128, 128, 128, 0.3)";
  const cell = {
    border,
    padding: "0.25rem 0.5rem",
    textAlign: "start",
    verticalAlign: "top"
  };
  return <details className="not-prose" style={{
    border,
    borderRadius: "0.5rem",
    margin: "0.5rem 0",
    padding: "0.5rem 0.75rem",
    fontSize: "0.8125rem",
    lineHeight: "1.125rem"
  }}>
      <summary style={{
    cursor: "pointer",
    fontWeight: 600,
    opacity: 0.72
  }}>
        版本历史
      </summary>
      <table style={{
    borderCollapse: "collapse",
    width: "100%",
    margin: "0.5rem 0 0"
  }}>
        <thead>
          <tr>
            {headers.map(header => <th key={header} style={{
    ...cell,
    fontWeight: 600,
    opacity: 0.72
  }}>
                {header}
              </th>)}
          </tr>
        </thead>
        <tbody>
          {rows.map((row, row_index) => <tr key={row.id ?? row_index}>
              {(row.items ?? []).map((item, item_index) => <td key={item_index} style={{
    ...cell,
    overflowWrap: "anywhere"
  }}>
                  {item?.label}
                </td>)}
            </tr>)}
        </tbody>
      </table>
    </details>;
};

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](/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](/zh/reference/system-tables/query_log) 表中 `log_comment` 字段的值，以及服务器日志中的注释文本。

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

可能的值：

* 不超过 [max\_query\_size](/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](/zh/reference/system-tables/query_log) 系统表中 (即填充 [system.query\_log](/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" />

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

另请参见：

* [`system.processors_profile_log`](/zh/reference/system-tables/processors_profile_log)
* [`EXPLAIN PIPELINE`](/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。
