From 142a3136d4eb870ead577da193ac9ec54d1a26f4 Mon Sep 17 00:00:00 2001 From: Deluan Date: Tue, 2 Dec 2025 14:24:15 -0500 Subject: [PATCH] fix: log warning when no config file is found Always log the configuration source at startup: shows an INFO message with the config file path when found, or a WARN message explaining how to specify one when not found. This helps users understand why CLI commands may fail when run outside of systemd (where --configfile is typically specified). Closes #4758 --- conf/configuration.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/conf/configuration.go b/conf/configuration.go index 9d7b1a3d0..58785952c 100644 --- a/conf/configuration.go +++ b/conf/configuration.go @@ -340,9 +340,16 @@ func Load(noConfigDump bool) { Server.BaseScheme = u.Scheme } + // Log configuration source + if Server.ConfigFile != "" { + log.Info("Loaded configuration", "file", Server.ConfigFile) + } else { + log.Warn("No configuration file found. Using default values. To specify a config file, use the --configfile flag or set the ND_CONFIGFILE environment variable.") + } + // Print current configuration if log level is Debug if log.IsGreaterOrEqualTo(log.LevelDebug) && !noConfigDump { - prettyConf := pretty.Sprintf("Loaded configuration from '%s': %# v", Server.ConfigFile, Server) + prettyConf := pretty.Sprintf("Configuration: %# v", Server) if Server.EnableLogRedacting { prettyConf = log.Redact(prettyConf) }