Skip to content
Bluetape4k docs1.11

Logger foundation

Latest stable Based on Bluetape4k release 1.11.0

The declaration style determines call-site ergonomics, name stability, and how operators identify a logger.

Responsibility boundary across KLogging, KotlinLogging, KLoggerFactory, and SLF4J

Use KLogging when a class or companion object should share a log property. Kotlin lazy creates the logger once on first access.

class InvoiceService {
companion object : KLogging()
fun issue() {
log.info { "Issuing invoice" }
}
}

Use KotlinLogging for top-level code, an explicit category, or a KClass name.

private val auditLog = KotlinLogging.logger("billing.audit")
private val fileLog = KotlinLogging.logger { }
val serviceLog = KotlinLogging.logger(InvoiceService::class)

logger(name) rejects a blank name with IllegalArgumentException. The lambda entry point and KLogging delegate synthetic and companion-name normalization to KLoggerNameResolver. Prefer an explicit category when the name is a stable dashboard or routing key.

The module returns SLF4J Logger; it does not install a backend. The application owns one provider such as Logback and its configuration. A library must not silently replace appenders or root levels.

SituationChoice
Every instance uses one categorycompanion KLogging()
File or top-level functionKotlinLogging.logger {}
Stable operational categorylogger("stable.name")
Explicit type-based categorylogger(Type::class)

Next: control evaluation cost and supplier failure in Lazy messages.