Skip to main content

Hexagon microservices toolkit

Klogging has a logging adapter for the Hexagon microservices toolkit.

Maven Central

info

Klogging supports Hexagon toolkit versions 3.4.3 and above, which requires JVM 17.

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.5.11")

// 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.5.11</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"
]
}
]
}
]
}