codeborne / klite

Kotlin async http server framework with coroutines and zero deps
MIT License
104 stars 17 forks source link

Cannot set custom logger in ".env" file #92

Open cbxp opened 3 days ago

cbxp commented 3 days ago

I want to use custom logger.

I created class CustomLogger:

class CustomLogger(name: String) : KliteLogger(name) {
  ...
}

I added this class to file ".env":

LOGGER_CLASS=com.app.CustomLogger

Expected result:

Class CustomLogger is used for logging

Actual result:

The default class KliteLogger is used instead of CustomLogger.

Hint

The reason is that this line is executed BEFORE reading ".env" file:

class KliteLoggerFactory: ILoggerFactory {
  private val loggers = ConcurrentHashMap<String, Logger>()
  private val loggerConstructor = findConstructor(Config.optional("LOGGER_CLASS", KliteLogger::class.java.name))