Lumina is a coroutine-first logging library for Kotlin.
It aims to be simple by default, but flexible enough when you need to configure it for more serious projects.
You get clean console output with ANSI colors, structured log files, and a DSL for building messages that don’t just end up as unreadable strings.
- Cleaner design: logging, configuration, and strategies are properly separated.
- DSL-based configuration (
createLogger { ... }). - Configurable log rotation with safe defaults.
- Structured message DSL (
logger.info { +"line"; keyValue { ... } }). - Better shutdown handling (
waitForCoroutinesToFinish). - Extensible strategies: build your own
LoggingStrategy.
implementation("dev.mtctx.lumina:lumina:4.1.1")<dependency>
<groupId>dev.mtctx.lumina</groupId>
<artifactId>lumina</artifactId>
<version>4.1.1</version>
</dependency>import mtctx.lumina.v4.*
fun main() {
val logger = createLogger {
name = "MyApp"
log {
rotation {
enabled = true
duration = 7.days
interval = 1.days
}
}
}
runBlocking {
logger.info { +"Lumina is ready" }
logger.error { +"Something went wrong" }
}
logger.waitForCoroutinesToFinish()
}Lumina ships with common levels:
- DEBUG
- INFO
- WARN
- ERROR
- FATAL
Each has both asynchronous (logger.info { ... }) and synchronous (logger.infoSync { ... }) variants.
Use sync logging only when you must flush logs immediately (for example, right before shutdown).
Instead of plain strings, you can build structured logs:
logger.info {
+"Application started"
keyValue {
define("Config", "dbUrl", "jdbc://localhost:5432")
}
+"Environment: production"
}If the default levels aren’t enough, you can create your own strategy:
val custom = LoggingStrategyBuilder(
strategyName = "CUSTOM",
ansiColor = ANSI.PURPLE,
config = myConfig,
fileSinks = mutableMapOf()
)Logger→LuminaLoggerConfig→LuminaConfig(with a new DSL)LogMessageDSL→MessageDSLwaitForCoroutinesFinish→waitForCoroutinesToFinish
v3 APIs are still present but deprecated, with migration hints in the code.
API reference: https://lumina.apidoc.mtctx.dev
Lumina is free software under the GNU GPL v3. Use it, modify it, and share it — just keep it free.