-
-
Notifications
You must be signed in to change notification settings - Fork 116
Multiplatform support
As of version 2.0 kotlin-logging composed of the following modules:
- Common - artifact id:
kotlin-logging
- JVM - artifact id:
kotlin-logging-jvm
- JS - artifact id:
kotlin-logging-js
- Linux - artifact id:
kotlin-logging-linuxx64
In order to include in gradle build file add the following dependency:
compile 'io.github.microutils:<artifact id>:<version>'
- First supported version is 2.0.2.
- It is sufficient to add the dependency on the common module.
Obtaining a logger is supported only by a field (no inheritance at the moment):
private val logger = KotlinLogging.logger {}
KLogger
log messages support only lazy methods messages such as:
logger.info { "Hello World!" }
All common interfaces and methods are supported.
In addition, in order to define log level set field KotlinLoggingConfiguration.LOG_LEVEL
during startup.
For example:
KotlinLoggingConfiguration.LOG_LEVEL = KotlinLoggingLevel.DEBUG
- Default level is
INFO
In JS there are many settings (browsers, node) that works a bit differently for name resolution. It is also possible to configure logger name like this (since version 4):
class MyClass {
private val logger by KotlinLogging.logger()
}
All common interfaces and methods are supported.
In addition, in order to define log level set field KotlinLoggingConfiguration.logLevel
during startup.
For example:
KotlinLoggingConfiguration.logLevel = KotlinLoggingLevel.DEBUG
- Default level is
INFO