> ## 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.

# Why is a system log table such as system.s3queue_log missing after I enabled it?

> System log tables such as system.s3queue_log are created by the first flush, not at server startup. Create them with SYSTEM FLUSH LOGS or with prepare_system_log_tables_on_startup.

The server does not create system log tables (`system.query_log`, `system.part_log`, `system.s3queue_log`, `system.azure_queue_log` and the other `*_log` tables) when it starts. It creates each table the first time it flushes rows into it. A log that has nothing to write yet has no table, even though its section is in the server configuration. To create the tables right away, run [`SYSTEM FLUSH LOGS`](https://clickhouse.com/docs/reference/statements/system#flush-logs).

## Example

Enable the log of the [`S3Queue`](https://clickhouse.com/docs/reference/engines/table-engines/integrations/s3queue) table engine in a file under `config.d` and restart the server:

```xml theme={null}
<clickhouse>
    <s3queue_log>
        <database>system</database>
        <table>s3queue_log</table>
    </s3queue_log>
</clickhouse>
```

The table is not there yet:

```sql theme={null}
SELECT count() FROM system.s3queue_log;
```

```text theme={null}
Code: 60. DB::Exception: Unknown table expression identifier 'system.s3queue_log'. In scope SELECT count() FROM system.s3queue_log. (UNKNOWN_TABLE)
```

Flush the log and check again:

```sql theme={null}
SYSTEM FLUSH LOGS s3queue_log;

SELECT name, engine
FROM system.tables
WHERE database = 'system' AND name = 's3queue_log';
```

```text theme={null}
   ┌─name────────┬─engine────┐
1. │ s3queue_log │ MergeTree │
   └─────────────┴───────────┘
```

The table now exists and is empty until an `S3Queue` table processes files.

## Why this happens

Every system log collects its rows in memory, and a background thread writes them to the table every `flush_interval_milliseconds` (7500 by default). The table is created by the first flush that has rows to write:

* `system.query_log` appears a few seconds after the first query.
* `system.s3queue_log` and `system.azure_queue_log` get rows only when an `S3Queue` or `AzureQueue` table processes files, so on a server without such tables they never appear by themselves.

`SYSTEM FLUSH LOGS` writes the collected rows immediately and also creates the tables of all configured logs, including the empty ones. With a list of names, such as `SYSTEM FLUSH LOGS s3queue_log, query_log`, it handles only those logs.

## Create the tables at startup

If scripts or monitoring queries expect the tables to exist from the start, set the server setting [`prepare_system_log_tables_on_startup`](https://clickhouse.com/docs/reference/settings/server-settings/settings/other#prepare_system_log_tables_on_startup) and restart the server:

```xml theme={null}
<clickhouse>
    <prepare_system_log_tables_on_startup>true</prepare_system_log_tables_on_startup>
</clickhouse>
```

The server then creates all configured `system.*_log` tables before it accepts queries. The setting is off by default. If `startup_scripts` are configured and the setting is not set explicitly, the server turns it on by itself.

## If the table is still missing

`SYSTEM FLUSH LOGS` creates tables only for logs that are configured, and it does not report a log whose section is absent. If the table does not exist after the flush, the server did not pick up the section:

* The section name must match the log, for example `s3queue_log` or `azure_queue_log`, and be a direct child of the root element.
* System logs are set up at startup, so restart the server after you add a section.
* The [preprocessed configuration file](https://clickhouse.com/docs/concepts/features/configuration/server-config/configuration-files.md#implementation-details) that the server writes at startup shows the configuration it uses.

## Related pages

* [System tables overview](https://clickhouse.com/docs/reference/system-tables/overview.md)
* [`system.s3queue_log`](https://clickhouse.com/docs/reference/system-tables/s3queue_log) and [`system.azure_queue_log`](https://clickhouse.com/docs/reference/system-tables/azure_queue_log)
* [`SYSTEM FLUSH LOGS`](https://clickhouse.com/docs/reference/statements/system#flush-logs)
