> ## 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_queries_* セッション設定

> log_queries_* 生成グループに含まれる 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/ja/reference/system-tables/settings) で確認でき、[ソースコード](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp) から自動生成されています。

<div id="log_queries">
  ## log\_queries
</div>

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

クエリのログ記録を設定します。

この設定を使用してClickHouseに送信されたクエリは、[query\_log](/docs/ja/reference/settings/server-settings/settings#query_log) サーバー設定パラメータのルールに従って記録されます。

例:

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

<div id="log_queries_cut_to_length">
  ## log\_queries\_cut\_to\_length
</div>

<SettingsInfoBlock type="UInt64" default_value="100000" />

クエリの長さが指定されたしきい値 (バイト単位) を超える場合、クエリログへの書き込み時にクエリを切り詰めます。また、通常のテキストログに出力されるクエリの長さも制限します。

<div id="log_queries_min_query_duration_ms">
  ## log\_queries\_min\_query\_duration\_ms
</div>

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

有効な場合 (0 以外の値) 、この設定値より短時間で完了するクエリはログに記録されません ([MySQL Slow Query Log](https://dev.mysql.com/doc/refman/5.7/slow-query-log.html) の `long_query_time` のようなものと考えることができます) 。つまり、これらのクエリは次のテーブルには記録されません。

* `system.query_log`
* `system.query_thread_log`

ログに記録されるのは、次のタイプのクエリだけです。

* `QUERY_FINISH`

* `EXCEPTION_WHILE_PROCESSING`

* 型: ミリ秒

* デフォルト値: 0 (すべてのクエリ)

<div id="log_queries_min_type">
  ## log\_queries\_min\_type
</div>

<SettingsInfoBlock type="LogQueriesType" default_value="QUERY_START" />

`query_log` に記録する最小の種別です。

設定可能な値:

* `QUERY_START` (`=1`)
* `QUERY_FINISH` (`=2`)
* `EXCEPTION_BEFORE_START` (`=3`)
* `EXCEPTION_WHILE_PROCESSING` (`=4`)

`query_log` に記録する項目を制限するために使用できます。たとえば、エラーのみを対象にしたい場合は、`EXCEPTION_WHILE_PROCESSING` を使用できます。

```text theme={null}
log_queries_min_type='EXCEPTION_WHILE_PROCESSING'
```

<div id="log_queries_probability">
  ## log\_queries\_probability
</div>

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

指定した確率でランダムに選択されたクエリのサンプルのみを、[query\_log](/docs/ja/reference/system-tables/query_log)、[query\_thread\_log](/docs/ja/reference/system-tables/query_thread_log)、および [query\_views\_log](/docs/ja/reference/system-tables/query_views_log) のシステムテーブルに記録できるようにします。これは、1 秒あたりのクエリ数が多い場合の負荷軽減に役立ちます。

設定可能な値:

* 0 — クエリはシステムテーブルに記録されません。
* 範囲 \[0..1] の正の浮動小数点数。たとえば、この設定の値が `0.5` の場合、クエリのおよそ半分がシステムテーブルに記録されます。
* 1 — すべてのクエリがシステムテーブルに記録されます。
