From 9f873b533410cb429973702bb963cdcc0245ad39 Mon Sep 17 00:00:00 2001 From: Ryuhei Furuta <38094415+Ryuheeeei@users.noreply.github.com> Date: Wed, 22 Oct 2025 15:51:45 +0900 Subject: [PATCH] KTOR-6610: feat: add debug log of ConfigLoader when server starts --- .../io/ktor/server/config/ConfigLoaders.kt | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ktor-server/ktor-server-core/common/src/io/ktor/server/config/ConfigLoaders.kt b/ktor-server/ktor-server-core/common/src/io/ktor/server/config/ConfigLoaders.kt index 56dbf56293a..c46ba86da64 100644 --- a/ktor-server/ktor-server-core/common/src/io/ktor/server/config/ConfigLoaders.kt +++ b/ktor-server/ktor-server-core/common/src/io/ktor/server/config/ConfigLoaders.kt @@ -4,8 +4,12 @@ package io.ktor.server.config +import io.ktor.util.logging.* + internal expect val CONFIG_PATH: List +private val logger = KtorSimpleLogger("io.ktor.server.config.ConfigLoader") + /** * Loads an application configuration. * An implementation of this interface should return [ApplicationConfig] if applicable configuration is found @@ -51,23 +55,34 @@ public interface ConfigLoader { */ public fun load(path: String? = null): ApplicationConfig { if (path == null) { + logger.debug("Loading default configuration") val default = loadDefault() if (default != null) return default } for (loader in configLoaders) { + logger.debug("Trying ConfigLoader: ${loader::class.simpleName}") val config = loader.load(path) - if (config != null) return config + if (config != null) { + logger.debug("Configuration loaded successfully using ${loader::class.simpleName} from path: $path") + return config + } } + logger.debug("No configuration found, using empty MapApplicationConfig") return MapApplicationConfig() } private fun loadDefault(): ApplicationConfig? { for (defaultPath in CONFIG_PATH) { + logger.debug("Trying default config path: $defaultPath") for (loader in configLoaders) { + logger.debug("Trying ConfigLoader: ${loader::class.simpleName} for path: $defaultPath") val config = loader.load(defaultPath) - if (config != null) return config + if (config != null) { + logger.debug("Default configuration loaded using ${loader::class.simpleName} from path: $defaultPath") + return config + } } }