oshai / kotlin-logging

Lightweight Multiplatform logging framework for Kotlin. A convenient and performant logging facade.
Other
2.63k stars 112 forks source link

KLogger does not properly populate SLF4J ILoggingEvent "message" field #449

Open neeme-praks-sympower opened 2 hours ago

neeme-praks-sympower commented 2 hours ago

Context

SLF4J ILoggingEvent has two important fields / getter methods:

This distinction is useful -- for example, we use this to aggregate log messages.

Issue

KLogger relies on Kotlin string interpolation and as a result, the message field contains the same formatted message as formattedMessage, breaking the possibilities for aggregation.

Proposal

Introduce a new field in KLoggingEventBuilder that could contain the log message template (e.g. "Hello $variable!"):

This will make it easier for me to implement something on top of KLogger to fill that field properly (I'm thinking of implementing a Kotlin compiler plugin).

github-actions[bot] commented 2 hours ago

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