Skip to content

Take an explicitly configured text_log.level into account when updating logger levels - #127717

Merged
azat merged 5 commits into
ClickHouse:masterfrom
nikita-vanyasin:text-log-level-root-logger-level
Oct 26, 2026
Merged

azat merged 5 commits into
ClickHouse:masterfrom
nikita-vanyasin:text-log-level-root-logger-level

Conversation

@nikita-vanyasin

@nikita-vanyasin nikita-vanyasin commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix text_log.level having no effect when it is set to a more verbose level than logger.level: messages below logger.level never reached system.text_log, neither at startup nor after a configuration reload. Behaviour is unchanged when text_log.level is not set.

Documentation entry for user-facing changes

No new settings. The level row of the text_log server setting (docs/reference/settings/server-settings/_server_settings_outside_source.mdx) and the comment in the default config.xml now state that an explicitly set text_log.level raises the root logger level, while an unset level is limited by the other log outputs.

Details

The root logger level is the gate in front of all log outputs and is meant to be the maximum of the configured output levels (see the comment in Loggers::buildLoggers). text_log is such an output with its own text_log.level, but neither Loggers::buildLoggers (startup) nor Loggers::updateLevels (initial configuration load, restore of logger.level after logger.startup_level, every SYSTEM RELOAD CONFIG) included it in that maximum. With for example:

<logger>
    <level>information</level>
</logger>
<text_log>
    <level>trace</level>
</text_log>

the root level was information and system.text_log silently lost everything below it, while the setting suggested otherwise.

This change adds an explicitly configured text_log.level to the maximum in both functions. The text_log channel keeps filtering at its own level, so the file log is still capped at logger.level.

An unset text_log.level (the shipped default, read as trace) is deliberately not counted: that would make every server with logger.level below trace start writing Trace and Debug rows into system.text_log. Such servers keep today's behaviour, the same convention as console_log_level, which also follows logger.level when unset.

New integration test test_text_log_level_after_reload checks that a startup Trace message (Initialized DateLUT ...) is in system.text_log, that Trace rows keep arriving after SYSTEM RELOAD CONFIG, and that the file log contains no Trace or Debug lines.

The failing Upgrade check (use_query_condition_cache_for_time_conditions not in the settings changes history) is unrelated to this change.

A follow-up (#127718) makes text_log.level itself reloadable.

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/127717]

Version info

  • Merged into: 26.11.1.793-master (included in 26.11 and later)
  • Backported to: 26.10.3.9, 26.9.26.19, 26.8.35.18

Loggers::buildLoggers computes the root logger level as the maximum of all
configured sinks, including text_log.level. Loggers::updateLevels, which is
called after startup (to restore logger.level from startup_level) and on
every configuration reload, only looked at the file, console, errorlog and
syslog levels. With logger.level below text_log.level the root level dropped
to the file level after startup or on the first reload, and system.text_log
silently lost every message below that level.

Include text_log.level in the computation in updateLevels as well, so that
a configuration such as logger.level=information with text_log.level=trace
keeps Trace and Debug messages in system.text_log while the file log stays
at information.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2fb3f88]

Summary: ✅


AI Review

Summary

An explicitly configured text_log.level now raises the root logger threshold during startup and configuration reloads, allowing more verbose messages in system.text_log while preserving file log filtering and behavior when the setting is absent. No remaining actionable findings; the previous startup finding is fixed. The focused integration regression and bugfix validation passed in CI on f27f0781; the final commit only removes comments.

Final Verdict

✅ Approve

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Oct 24, 2026
@nikita-vanyasin

Copy link
Copy Markdown
Member Author

@nerve-bot WDYT?

@clickhouse-gh clickhouse-gh Bot added the comp-logging Logging/monitoring/observability (logs, metrics, tracing, instrumentation). label Oct 24, 2026
@nikita-vanyasin

Copy link
Copy Markdown
Member Author

@groeneai wdyt?

The default configuration enables text_log without a level, which means
"trace". Counting that default towards the root level would make every
server with logger.level below trace start writing Trace and Debug
messages into system.text_log. Keep the previous behaviour for an unset
text_log.level and only raise the root level when it is set explicitly.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@nikita-vanyasin nikita-vanyasin changed the title Take text_log.level into account when updating logger levels Take an explicitly configured text_log.level into account when updating logger levels Oct 24, 2026
@mintlify

mintlify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit 2fb3f88.

Approve preview

@groeneai

Copy link
Copy Markdown
Collaborator

The approach looks right to me, and counting only an explicit text_log.level is the safe choice for the shipped config.

One gap: buildLoggers does not count text_log.level either. In Loggers.cpp#L285-L307 the level only goes to addTextLog; the root gets the max of the file, errorlog, syslog and console levels. So with this PR the root still stays at information from BaseDaemon::initialize (BaseDaemon.cpp#L423) until the main ConfigReloader applies the initial config (Server.cpp#L2633, updateLevels at #L2804), and Debug/Trace from that window never reach system.text_log.

Measured on a current master build (b866a0ab):

  • logger.level=information + text_log.level=trace: system.text_log has only Information (57) and Warning (4) rows from the first message on, not only after a reload.
  • logger.level=trace: 18 Debug/Trace rows (rlimits, Initialized DateLUT ..., DNS cache, AsynchronousMetrics scans) are logged before the initial Loading config row, i.e. inside that window.

The same rule in buildLoggers, inside the if (allowTextLog() && config.has("text_log")) block, closes it and makes both functions agree:

if (config.has("text_log.level"))
    max_log_level = std::max(text_log_level, max_log_level);

The test could then also check the startup part, e.g. that the Application Trace row Initialized DateLUT ... is in system.text_log.

@cv4g cv4g added the can be tested Allows running workflows for external contributors label Oct 24, 2026
Comment thread src/Loggers/Loggers.cpp Resolved
@clickhouse-gh

clickhouse-gh Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Commit 2fb3f8826cf68ac40698719d59ce1179843b04ff was not compared: the CI logs cluster did not answer (exception 241, code 500: Code: 241. DB::Exception: (total) memory limit exceeded: would use 212.40 …).

See the job log for details.

buildLoggers only passed text_log.level to the text_log channel and did
not include it in the root logger level, so with logger.level below
text_log.level the Debug and Trace messages logged before the initial
configuration load never reached system.text_log. Use the same rule as in
updateLevels, and assert in the test that a startup Trace message is in
system.text_log.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@nikita-vanyasin

Copy link
Copy Markdown
Member Author

@groeneai check this new version

@groeneai

Copy link
Copy Markdown
Collaborator

Looks right to me now.

  • buildLoggers and updateLevels apply the same rule (allowTextLog() plus an explicit text_log.level), so with text_log.level set the root level no longer drops between startup and the first config load, and with it unset nothing changes.
  • The test covers both halves. Initialized DateLUT (Server.cpp:2116) is logged after buildLoggers (BaseDaemon.cpp:423) and before the first updateLevels (the initial ConfigReloader load, Server.cpp:2633), so it only reaches system.text_log through the buildLoggers change. The Trace rows after startup and after SYSTEM RELOAD CONFIG need the updateLevels change.
  • CI on f27f078: the new test passes in 5 integration jobs including the flaky check, and Bugfix validation (integration tests) passed on amd64 and aarch64, so it fails on master.

No further comments from me.

@nikita-vanyasin
nikita-vanyasin marked this pull request as ready for review October 24, 2026 17:04
@azat azat self-assigned this Oct 26, 2026
Comment thread src/Loggers/Loggers.cpp Resolved
Comment thread src/Loggers/Loggers.cpp Resolved
@azat
azat enabled auto-merge October 26, 2026 13:35
@azat
azat added this pull request to the merge queue Oct 26, 2026
Merged via the queue into ClickHouse:master with commit 8822a14 Oct 26, 2026
179 checks passed
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 26, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Oct 26, 2026
@robot-clickhouse robot-clickhouse added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Oct 26, 2026
clickhouse-gh Bot added a commit that referenced this pull request Oct 26, 2026
Backport #127717 to 26.10: Take an explicitly configured text_log.level into account when updating logger levels
clickhouse-gh Bot added a commit that referenced this pull request Oct 26, 2026
Backport #127717 to 26.8: Take an explicitly configured text_log.level into account when updating logger levels
clickhouse-gh Bot added a commit that referenced this pull request Oct 26, 2026
Backport #127717 to 26.9: Take an explicitly configured text_log.level into account when updating logger levels
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…l into account when updating logger levels
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…l into account when updating logger levels
leshikus pushed a commit that referenced this pull request Nov 13, 2026
…el into account when updating logger levels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-logging Logging/monitoring/observability (logs, metrics, tracing, instrumentation). pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo v26.6-must-backport v26.8-must-backport v26.10-must-backport

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants