https://kotlinlang.org logo
Title
m

Milan Hruban

01/07/2021, 11:31 AM
When using slf4j (or other) loggers, do you use 1️⃣ string interpolation -
<http://logger.info|logger.info>("the value is $value")
2️⃣ passing additional arguments -
<http://logger.info|logger.info>("the value is {}", value)
3️⃣ :thread-please: something else?
2️⃣ 5
a

arekolek

01/07/2021, 11:33 AM
"... {}"
for logs that need to be removed by R8
m

Matteo Mirk

01/07/2021, 11:41 AM
2️⃣ is the intended way, it guarantees that the message won’t be interpolated if the corresponding level is not active
c

christophsturm

01/07/2021, 12:28 PM
kotlin logging:
logger.debug { "hello $message" }
imo even better than 2
👍 1
a

arekolek

01/07/2021, 12:54 PM
logger.debug { "hello $message" }
I'm not sure what ☝️ is, something you defined on your own?
d

dave08

01/07/2021, 2:46 PM
#kotlin-logging
It's a library
👍 2
j

James Richardson

01/07/2021, 6:34 PM
Have you considered using structured logging, then no string interpolation is required...