Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request LoggingEventAware(slf4j) support #319

Closed
be-hase opened this issue May 29, 2023 · 4 comments
Closed

Request LoggingEventAware(slf4j) support #319

be-hase opened this issue May 29, 2023 · 4 comments

Comments

@be-hase
Copy link

be-hase commented May 29, 2023

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

@github-actions
Copy link

Thank you for reporting an issue. See the wiki for documentation and slack for questions.

@oshai
Copy link
Owner

oshai commented May 31, 2023

Hi,
At the moment I do not plan to support fluent logging. If you wish to contribute that we can discuss implementation.

@be-hase
Copy link
Author

be-hase commented Jun 5, 2023

Thanks for the reply.
I will consider for a while how it should be implemented.

@oshai
Copy link
Owner

oshai commented Jul 11, 2023

This is added as part of v5 in #329

@oshai oshai closed this as completed Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants