Skip to content

Comments

Log config warnings in the logs, not on stderr#7621

Open
alexbozhenko wants to merge 1 commit intomainfrom
alex/log_warn_config_warnings
Open

Log config warnings in the logs, not on stderr#7621
alexbozhenko wants to merge 1 commit intomainfrom
alex/log_warn_config_warnings

Conversation

@alexbozhenko
Copy link
Member

@alexbozhenko alexbozhenko commented Dec 5, 2025

Currently, config parsing warnings are printed on stderr.

# nats-server -c test.conf  --log log.out
test.conf:9:1: invalid use of field "ping_interval": ping_interval should be converted to a duration

Depending on how the server is deployed(systemd, k8s, nix, etc...) and how the logs are aggregated, this stderr may be lost and will not show up where all the other nats servers logs are.

Test plan:

This will make print the config parsing warnings using whatever logging we configured, not on stderr, where it can be never noticed.

# ./nats-server -c test.conf  --log log.out
# cat log.out
[95618] 2025/12/05 14:49:44.456825 [INF] Starting nats-server
[95618] 2025/12/05 14:49:44.456893 [INF]   Version:  2.14.0-dev
...
[95618] 2025/12/05 14:49:44.456932 [INF] Using configuration file: test.conf (sha256:d20faaf4b973de79fbfcc43c0c4784365473a235a04d681c8a6df05e5781ba91)
[95618] 2025/12/05 14:49:44.456941 [WRN] Configuration warning: test.conf:9:1: invalid use of field "ping_interval": ping_interval should be converted to a duration
...
[95618] 2025/12/05 14:49:44.459155 [INF] Listening for client connections on 0.0.0.0:4222
[95618] 2025/12/05 14:49:44.459963 [INF] Server is ready

Signed-off-by: Alex Bozhenko alexbozhenko@gmail.com

Signed-off-by: Alex Bozhenko <alexbozhenko@gmail.com>
@alexbozhenko alexbozhenko marked this pull request as ready for review December 5, 2025 22:55
@alexbozhenko alexbozhenko requested a review from a team as a code owner December 5, 2025 22:55
Copy link
Member

@neilalexander neilalexander left a comment

Choose a reason for hiding this comment

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

My understanding is that we always write these configuration errors directly to stderr as we don't know at that point whether we have successfully parsed any other log-related options that could redirect them elsewhere or obscure them from view.

Do you have any thoughts @derekcollison?

(To my knowledge Kubernetes and systemd both capture stdout+stderr by default, can't speak for Nix though.)

@derekcollison
Copy link
Member

IIRC we do stderr for errors and warnings and stdout for INFO. But I would need to look, that was done over a decade ago.

@github-actions github-actions bot added the stale This issue has had no activity in a while label Feb 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue has had no activity in a while

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants