Request `LoggingEventAware`(slf4j) support
be-hase opened this issue · 4 comments
key-value pair was introduced in slf4j 2.x.
For example, we can write like this.
Depending on the implementation of appender, key-value pairs can be sent as structured logs.
logger.atInfo().addKeyValue("key1", "value1").log("some message")
However, KLogger does not implement LoggingEventAware, so key-value pairs cannot be used properly.
https://github.com/oshai/kotlin-logging/blob/3.x/src/jvmMain/kotlin/mu/KLogger.kt#L12
Currently this code branch has been executed. Therefore, I would like KLogger to implement LoggingEventAware.
https://github.com/qos-ch/slf4j/blob/f871e7f2e9f3f3959e987967655dfcb15494a3d3/slf4j-api/src/main/java/org/slf4j/spi/DefaultLoggingEventBuilder.java#L149
Of course, we can write the following. However, it is more time-consuming and easy to make mistakes...
logger.underlyingLogger.atInfo().addKeyValue("key1", "value1").log("some message")
I am aware that kotlin-logging will change significantly in ver4, but it does not seem to be supported in ver4.
https://github.com/oshai/kotlin-logging/blob/master/src/commonMain/kotlin/io/github/oshai/KLogger.kt
Thank you for reporting an issue. See the wiki for documentation and slack for questions.
Hi,
At the moment I do not plan to support fluent logging. If you wish to contribute that we can discuss implementation.
Thanks for the reply.
I will consider for a while how it should be implemented.