Skip to content

Allow setting the log level and log file via env and CLI - #331

Merged
benthecarman merged 1 commit into
lightningdevkit:mainfrom
SovereignTechnology:config/noissue-log-level-env
Nov 10, 2026
Merged

benthecarman merged 1 commit into
lightningdevkit:mainfrom
SovereignTechnology:config/noissue-log-level-env

Conversation

@SovereignTechnology

Copy link
Copy Markdown
Contributor

docs/configuration.md says every config key can also be set through an LDK_SERVER_* environment variable or a CLI flag. [log] level and [log] file could only be set in the TOML: ArgsConfig had flags for the other four log keys (max_size_mb, rotation_interval_hours, max_files, log_to_file) but not these two.

We hit this while running ldk-server under systemd: raising the log level for a debugging session meant generating a second config file and overriding ExecStart, instead of a one-line Environment=LDK_SERVER_LOG_LEVEL=Debug drop-in.

Change

  • ArgsConfig: --log-level / LDK_SERVER_LOG_LEVEL and --log-file / LDK_SERVER_LOG_FILE, next to the existing log flags. They follow the same TOML-key → flag → env naming.
  • merge_args: both override the TOML value, like every other arg. The level string is still validated in build(), so an invalid value from the environment fails exactly like an invalid TOML value.
  • Tests:
    • default_args_config() now sets both.
    • test_config_from_args_config and test_args_config_overrides_file assert log_level and log_file_path. Their expected configs already listed these fields, but no assertion checked them.
    • test_invalid_log_level_in_args_config covers the error path.
  • docs/configuration.md: the [log] section names the two new flags and variables.

Testing

Mirroring the MSRV leg of build.yml, with idna_adapter pinned to 1.2.0:

  • cargo +1.85.0 clippy --all-features -- -D warnings: clean.
  • cargo +1.85.0 test --all-features: all suites pass.
  • cargo fmt --all -- --check, and the same for e2e-tests: clean.
  • ldk-server --help lists both flags with their env names.

Unrelated to this change: clippy on current stable (1.98) reports result_large_err twice in ldk-server-cli/src/pay_wait.rs (lines 100 and 119). CI runs clippy only on 1.85, so it doesn't fail there.

Disclosure: this change was written with an AI coding assistant (Claude Code); we reviewed it and ran the tests above.

`[log] level` and `[log] file` could only be set in the config file,
while the other log options and the rest of the config can also be set
through `LDK_SERVER_*` environment variables and CLI flags, as
docs/configuration.md describes. Add `--log-level` / `LDK_SERVER_LOG_LEVEL`
and `--log-file` / `LDK_SERVER_LOG_FILE`, merged like the other args so
they override the config file. The level is still validated in `build()`.

The args-config tests listed these fields in their expected configs but
never asserted them; assert them now, and cover an invalid level given
through the args.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ldk-reviews-bot

ldk-reviews-bot commented Nov 10, 2026 •

Copy link
Copy Markdown

I've assigned @benthecarman as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@benthecarman benthecarman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@benthecarman
benthecarman merged commit c6a3be6 into lightningdevkit:main Nov 10, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants