Hexagon microservices toolkit
Klogging has a logging adapter for the Hexagon microservices toolkit.
info
Klogging supports Hexagon toolkit versions 3.4.3 to 3.4.7, which require JVM 17.
Later versions of Hexagon toolkit use JDK Platform Logging and do not require this adapter. To use Klogging with these versions, use the JDK Platform Logging implementation instead.
Specify dependency
Specify the adapter dependency in Gradle, for example:
dependencies {
implementation("com.hexagonkt:http_server_jetty:3.4.7")
implementation("io.klogging:hexagonkt-klogging-adapter:0.7.3")
// etc.
}
Or in Maven, for example:
<dependencies>
<dependency>
<groupId>com.hexagonkt</groupId>
<artifactId>http_server_jetty</artifactId>
<version>3.4.7</version>
</dependency>
<dependency>
<groupId>io.klogging</groupId>
<artifactId>hexagonkt-klogging-adapter</artifactId>
<version>0.7.3</version>
</dependency>
<!-- etc. -->
</dependencies>
Install the adapter
At the beginning of the main function, set the adapter to use, for example:
fun main() {
LoggingManager.adapter = KloggingManager()
server.start()
}
Configure Klogging
Configure Klogging either using the configuration DSL or a
configuration file in the application classpath. Here is a simple klogging.json
example:
{
"sinks": {
"console": {
"renderWith": "RENDER_ANSI",
"sendTo": "STDOUT"
}
},
"logging": [
{
"levelRanges": [
{
"fromMinLevel": "INFO",
"toSinks": [
"console"
]
}
]
}
]
}