Hi,
I am using Apache Logging library (org.apache.logging.log4j) to log various things as part of my server stack.
Using code block similar to below generates following type of Log statements in the server logs… Why is the log prefix NOT that of Kotlin class through which instance of Log4j is created? This happens only when I log statements from within lambda functions like also
.
class KotlinClass {
companion object {
val LOG = org.apache.logging.log4j.LogManager.getLogger(KotlinClass::class)
}
...
...
fun doSomething() {
LOG.info("Inside doSomething() method")
val isValid = getValid().also {
LOG.info("Obtained valid result $it")
}
}
Server generated LOG:
...
TIMESTAMP.. com.abcd.efgh.KotlinClass: Inside doSomething() method
TIMESTAMP.. Kotlin.jvm.internal.ClassReference: Obtained valid result false
...
Any idea on what can be done to log ‘Class Name’ as prefix irrespective of where the log is being generated?