> ## 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_* session settings

> ClickHouse session settings in the log_queries_* generated group.

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
  }}>Type</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{type}</div>
      <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>Default</div>
      <div style={{
    overflowWrap: "anywhere"
  }}>{default_value}</div>
      {changeable_without_restart && <div style={{
    fontWeight: 600,
    opacity: 0.72,
    marginInlineStart: "0.5rem"
  }}>
          Changeable without restart
        </div>}
      {changeable_without_restart && <div style={{
    overflowWrap: "anywhere"
  }}>
          {changeable_without_restart}
        </div>}
    </div>;
};

These settings are available in [system.settings](/docs/reference/system-tables/settings) and are autogenerated from [source](https://github.com/ClickHouse/ClickHouse/blob/master/src/Core/Settings.cpp).

<h2 id="log_queries">
  log\_queries
</h2>

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

Setting up query logging.

Queries sent to ClickHouse with this setup are logged according to the rules in the [query\_log](/docs/reference/settings/server-settings/settings#query_log) server configuration parameter.

Example:

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

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

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

If query length is greater than a specified threshold (in bytes), then cut query when writing to query log. Also limit the length of printed query in ordinary text log.

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

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

If enabled (non-zero), queries faster than the value of this setting will not be logged (you can think about this as a `long_query_time` for [MySQL Slow Query Log](https://dev.mysql.com/doc/refman/5.7/slow-query-log.html)), and this basically means that you will not find them in the following tables:

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

Only the queries with the following type will get to the log:

* `QUERY_FINISH`

* `EXCEPTION_WHILE_PROCESSING`

* Type: milliseconds

* Default value: 0 (any query)

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

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

`query_log` minimal type to log.

Possible values:

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

Can be used to limit which entities will go to `query_log`, say you are interested only in errors, then you can use `EXCEPTION_WHILE_PROCESSING`:

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

<h2 id="log_queries_probability">
  log\_queries\_probability
</h2>

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

Allows a user to write to [query\_log](/docs/reference/system-tables/query_log), [query\_thread\_log](/docs/reference/system-tables/query_thread_log), and [query\_views\_log](/docs/reference/system-tables/query_views_log) system tables only a sample of queries selected randomly with the specified probability. It helps to reduce the load with a large volume of queries in a second.

Possible values:

* 0 — Queries are not logged in the system tables.
* Positive floating-point number in the range \[0..1]. For example, if the setting value is `0.5`, about half of the queries are logged in the system tables.
* 1 — All queries are logged in the system tables.
